Error while trying to create admin user: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [1044] Access denied for user 'newuser'@'localhost' to database 'new-database'

So I have been using NC since they split form OC. Was using OC for several years before that. Today I set about moving from an old server to a new box. Old machine was running Ubuntu 16.04 and the new box 18.04.

I downloaded NC15 and NC14 and attempted to install each one as a test site and attempted to go through the installation setup. I get the following error

Error while trying to create admin user: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [1044] Access denied for user ‘newuser’@‘localhost’ to database ‘new-database’

I have created a new user and given it full permissions because I see that the root user may have problems. This made no difference.

I have attempted to create the database first and not create the database first. No difference.

I have attempted to use in place of localhost no difference.

I am stumped as to how to get this to work. In an effort to test my server I downloaded wordpress and had it installed and operating in about 2 minutes. So the server is working fine. Could there be something missing setup wise. I am not seeing much in the log files during this either.

Thanks for any help you can provide.

OK, so some additional information. I tried installing again but this time I made sure the user that nextcloud would create was not already a user. Then I set the non existent user to have permission to the database I was pointing the install towards. This worked. So there is a problem giving the new user the proper permissions. The problem with the install is when you try to manually assist by fixing permissions and rerun the install it generates a user1, user2, user3 so you have to be ahead of the installer.

I hope this give someone an idea of how to help me fix this issue.


I’m having the same issue, it’s driving me crazy. I’m trying to get Nextcloud going in a docker container, but every time I try to get the initial startup, it does not use my environmental attributes and creates a numbered version of my admin account I’m trying tot create.

I’m up to admin_33 now.

I changed my original question as I figure out today that my transferred installations from my old server were having a redis memcache issue. I removed that from the config file and the sites lit right up. Now I have to figure out that issue. The error when attempting to install is still there. I have a work around but it’s a pain.

I can answer this for people. The username and database password in the config file are just as they are in the database. So the password is not salted. I was able to create the user with the listed password in the new database and it works. I ran across some discussion on this matter while trying to get my sites working.

In case anyone else encounters this too (i got it after migrating to a new system by restoring database backup):

This (…) occurs because the database user created for Nextcloud has permission to create new users, but is not allowed to grant permissions.

Log in to mysql with

sudo mysql --user=root mysql

Then run

grant all privileges on *.* to 'database username'@'localhost' with grant option;

Exit with CTRL+D

1 Like

Dude, saved me. Thank you so much.

Hi all together,
I had the same problem with a wrong suffix attached to the DB user, which I couldn’t solve at first.

Environment: synology disc station 218+ with DSM 6.2.3, Apache 2.4, MariaDB10, installed locally on disk station, no docker image in use.

I created the user ‘NextCloud’@‘localhost’ creating a database of the same name in php myAdmin. Then I put in the db-username “NextCloud” and the database name “NextCloud” into the installer screen and kept the host entry ‘localhost’ untouched.

The error was a different one (doesn’t matter here) and so I changed it to the IP-address of the synology host.


The error contained the username, that was used:

The required username is ‘NextCloud’@‘localhost’, as the db- user was created.

For Maria DB10 we need to use (or whatever port you have configured) as host in the respective field.

Because I used the IP address in the local network instead of, the installer added the fqdn to the username instead of localhost.

Problem - soved.