Nextcloud setup is driving me crazy! Problem is the following message when I go through the setup wizard:
Error while trying to create admin user: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000]  Access denied for user 'oc_admin'@'172.18.0.1' (using password: YES)
I had it working an then it went haywire. See this post.
The oc_admin-user did not have the privileges to DROP DATABASE. With the root-user I couldn’t grant the privileges no matter how hard I tried. Hence I couldn’t delete database content and went for the nuclear option: deleting config and reinstalling from scratch.
Everything is dockerised and at the latest releases. Below my docker-compose file for nextcloud and mariadb the #-sign is to go to a “minimal” working example at which I have not arrived yet. (Allthough, before it went haywire, everything worked like charm when uncommented.)
When I understand everything correctly there shouldn’t be any compatibility issues.
Details and solutions tried:
The connection to the mariadb with the root-user works: When installing mariadb from scratch, I can login and check for already created databases. Once I click finish installation in the setup wizard, the database nextcloud is created (as I entered in the respective field).
So the problem seems that root cannot create the oc_admin-user allthough it can access mysql and create the database
So far I tried:
Manually creating the oc_admin-user and grant respective privileges (one of the solutions suggested in forums). No use: Nextcloud tries to create oc_admin1 with the same issues.
Any ideas? Seriously, it’s driving me nuts - I already spent hours (literaly) trying to solve the problem.
I am using LibreElec and run Docker Containers from Linuxserver.io which LE provides with a wrapper as easy installable addons. MariaDB is already up and running and KODI is successfully storing the movie data there.
Now I installed nextcloud 10 from Linuxserver.io and call the web gui 1st time to configure nextcloud. I had prepared the db user and db in the bash of the container with the SQL commands.
But when I try to create user admin with the entries for a “MySQL/MariaDB” I get the error back "SQLSTATE[HY000]  Access denied for user ‘oc_admin’@‘172.18.0.1’ "
Creating the nextcloud DB in the docker start command is not an option for me because the DBMS is used for several apps and hold already lot of data…
One year ago with earlier version of nextcloud I could manage to setup in this way, now not anymore. What can be the reason?
in the end I made it !
it looks as the V18 is still not completely free of temporary developers hacks
I looked into config.php and saw the it has fixed values that come not from my input in the 1st use at the login page but which seem to be hard wired ! Look yourself, you will find something like :
‘dbname’ => ‘ncdb’,
‘dbhost’ => ‘xxxxxxxxxxxxxxxxx:3306’,
‘dbport’ => ‘’,
‘dbtableprefix’ => ‘oc_’,
‘mysql.utf8mb4’ => true,
‘dbuser’ => ‘oc_admin’,
‘dbpassword’ => ‘xxxxxxxxxxxxxxxxxxx’,
Your individual values replace xxxxxxxxx, I created user and db like this (Password is oc_admin) before I started the web guide 1st time and now it works!
Yes, I created the user/password and the db manually in MariaDB (using “DBeaver”) AND used the same in the web-gui 1st access. I guess that the content of config.php was created at setup including the encrypted Password (“hard-wired”). check your config.php content !
I found the file and I try to create the user on MariaDB manually (command line), an empty database has already created. Doing that, running again the setup I get the same error message trying to create a second user:
Error while trying to create admin user: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000]  Access denied for user 'oc_admin1'@'localhost' (using password: YES)
I also try to install a precedent version of nextcloud, no way. It doesn’t works.
sudo /usr/local/mariadb10/bin/mysql --user=root --password=sadKS3f_z5sif nextcloud
create database nextcloud;
create user nxtcloudadmin@localhost identified by ‘admin123’;
grant all privileges on nextcloud.* to nxtcloudadmin@localhost identified by ‘admin123’;
I tried many things, read many tips, until I figured it out.
Install Apache with php.
Install MariaDB and secure it with:
(That gives a password to the root account.)
Added the lines at the bottom of my.conf.
Needed to do a
update mysql.user set plugin = ‘mysql_native_password’ where user=‘root’
otherwise I couldn’t log in.
(hindsight: Probably was a mistake. I should have logged in to phpMyAdmin as user phpmyadmin, not as root)
Then phpMySQL was up and running.
Then installed nextcloud and run into the often described problem.
One needs to understand, on the first configuration screen:
“User name” and corresponding password are for a future admin user of NextCloud.
“Database user” and corresponding password are NOT root, but a nextcloud-internal user that is used to access the database.
Use phpMyAdmin to create the “Database user” with password. Grant all privileges on the database. Means: select the database, then privileges, new user …
To be sure, in the next step select that new user and give him also the grant rights on that database. Maybe not needed, but I saw it in several solutions.
Then edit the nextcloud/config/config.php file.
dbuser: Database user
dbpassword: the password of the Database user in clear text (i.e. not encrypted).
And voila, enter the data at the initial config screen, and it works.
I fixed the config.php as your solution,but it seems did not work and had a new problem:
Internal Server Error
The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.
YES. This error is caused by mixing up the username and the database user.
The Admin USERname (on top) is put in the field for the database-user.
The system is generating a password for the databaseuser, one that is not input.
So Nextcloud has no access to the database with these wrong credentials.
Hello everybody. I know this post has been inactive for more than two years, but I’m still getting this error while trying to configure Nextcloud 18 on Ubuntu 20.04.
I took a look also at this discussion, but it hasn’t been of much help, unfortunately.
I Have the latest versions of MySQL, Apache and php.
I went through the steps @berniejo suggested, but nextcloud won’t allow me to use the same user I previously configured, it adds an index at the end to create a new user. In my case, if I tried another time, I’d get: 'oc_xplosionmind1'
Please help me, I’m getting crazy!
NOTE: not using Docker or Docker compose as @akrea
@xplosionmind did you find a solution ? I have the same error and tried most of what is mentioned in this tread but nothing worked. I’m on Synology with MariaDB10 but it looks like the same problem happens whatever the server type is.
It was a MariaDB 5 vs 10 problem. localhost was pointing to MariaDB5 on port 3306 but even if I force to localhost:3307 it was looking in MariaDB5. The solution was to use 188.8.131.52:3307, no idea why it makes any difference between localhost and 184.108.40.206:3307 but it works now!