Nexcloud 16 Installation Error while trying to create admin user: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [1045] Access denied

Hello,

I have the error below when I try to install Nextcloud (16.0.1)

Error while trying to create admin user: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [1045] Access denied for user ‘nextcloud_usr’@‘host.com’ (using password: YES)

I can connect successfully to mysql with the MySQL CLI and check if the user has the rights permissions:

mysql -u nextcloud_usr -h host.com -p 

[...] 

mysql> show grants for 'nextcloud_usr';
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for nextcloud_usr@%                                                                                                                                                                                                                                                                                                                                                                                                                      |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `nextcloud_usr`@`%` WITH GRANT OPTION                                       |
| GRANT APPLICATION_PASSWORD_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,GROUP_REPLICATION_ADMIN,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SYSTEM_USER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,XA_RECOVER_ADMIN ON *.* TO `nextcloud_usr`@`%` WITH GRANT OPTION |
| GRANT ALL PRIVILEGES ON `nextcloud_db`.* TO `nextcloud_usr`@`%` WITH GRANT OPTION                                                                                                                                                                                                                                                                                                                                                               |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
3 rows in set (0,00 sec)

I use MySQL 8.0.16 on a distant server and I changed the authentication plugin for nextcloud_usr

mysql> select user, plugin from mysql.user;
+------------------+-----------------------+
| user             | plugin                |
+------------------+-----------------------+
| nextcloud_usr    | mysql_native_password |
| mysql.infoschema | caching_sha2_password |
| mysql.session    | caching_sha2_password |
| mysql.sys        | caching_sha2_password |
| root             | caching_sha2_password |
+------------------+-----------------------+
5 rows in set (0,00 sec)

I am going crazy… :pleading_face:
Any advice ?

Regards.

Replace host.com by localhost on the installation wizard.

Thanks me after.

I wrote “host.com” in the message above because I replaced the real value for this forum :slight_smile:

And testing with localhost gave you a bad install ?

Your mysql server is on the same host as the webserver where nextcloud is ?

No, the MySQL server and Nextcloud application are on 2 separated servers.

Nexcloud doesn’t connect to the MySQL server successfully (cf. error above) but with the MySQL CLI (from the application server to the database server) : I can !

Sorry i reed to quickly.
I think Mysql 8.0 could have errors for the moment with nextcloud 16.

You should talk about that on the github of nextcloud/server.

And what about php ? Your version is 7.0 - 7.1 - 7.2 - 7.3 ? Did you install the php module php7.x-mysql ?

Another problem you will face Nextclound 16 and MySQL 8.0.16

I always make good choices… :sweat_smile:

I use PHP 7.3 and php7.3-mysql is installed (If not well installed, I think the wizzard doesn’t even show MySQL parameters ?).

You are right. Something you can test :

1- install mysql 8.0 on your webserver
2- make the install saying localhost
3- make a dump of your local mysql and inject it into the distant mysql
4- modify your nextcloud config.php about the mysql (host, db user, db name, password)

Tell if it’s better.
Another thing does your Webserver and mysql server are on the same lan ?

I will try that if response from github.
Both servers are on the same lan and, as I wrote, I successfully connect to MySQL server from the application server using the MySQL CLI (so I assume there is no network issue).

I ask that because having Webserver and Mysql server on separate network (one in town A, another in town B) is really a bad idea because Nextcloud is a heavy compagnon on his Mysql server. Doing that will giving you really poor performances.

Having both server on the same LAN is the only way to have Mysql server on another host than the webserver

A connection error on the first configuration was driving me crazy. I had extracted the zip file contents to a directory at my web hosting provider, created a new mariadb database throuhg a web-interface they provide and ensured that the automatically added user had read/write privileges. Then navigated to the directory containing the nextcloud files on my web-site and the first configuration screen appered.

Althoug, every time the requested fields (admin name, password and database username, password, name and server) were filled in with apropriate values the initiation failed with an access error.

I checked and double checked every field, tried with and without port number, using server name and server IP (localhost was not an option for me as dbserver is on some cluster)… well every single combination failed. And google searches gave no good advice… until someone mentioned this:

DO NOT use the VIEW PASSWORD icon in the password fields! Just type the passwords so the dots are shown and voila! It worked :astonished: