Error while trying to create admin user during setup

Hi. I’ve setup a nginx server with PHP-FPM and MariaDB 10.4. The install is failing when it attempts to create the admin user on the database server.

Per the manual I used the root user to connect to the mariadb server (Expecting that it would create the database and nextcloud admin user). When that failed I did some looking and noticed that there appears to have been a change in the way mariadb authentication works since the last time I did this so using the root user on the database server I created a local database admin user:

CREATE USER ‘admin’@‘localhost’ IDENTIFIED BY ‘AdminPassword’;

then attempted the setup again with the new admin user. I received the same error. Using both the admin and root users (on the server in the terminal) I checked and saw that the database was created which means the installer was able to connect to the server however the oc_admin user wasn’t created.

I thought maybe there was a permission issue with the admin account so (again from the terminal, logged in as the database admin user) I tried to make a ‘testuser’:

CREATE USER ‘admin’@‘localhost’ IDENTIFIED BY ‘TestPassword’;

this worked fine, so it there doesn’t appear to be anything wrong with the database server.

At this point I’m out of ideas. I’m using PHP 7.3 on FreeBSD with nginx 1.16.1 and nextcloud tar version 17.0.2

CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; 
CREATE USER nextcloud@localhost identified by 'nextcloud'; 
GRANT ALL PRIVILEGES on nextcloud.* to nextcloud@localhost; 
FLUSH privileges; 


sudo -u www-data php /var/www/nextcloud/occ maintenance:install --database "mysql" --database-name " **nextcloud** " --database-user " **nextcloud** " --database-pass " **nextcloud** " --admin-user " **YourNextcloudAdmin** " --admin-pass " **YourNextcloudAdminPasssword** " --data-dir "/var/nc_data"

you have to create the oc_admin user. in the above example Carsten is using the user nextcloud.

Ok I’ll try this. This isn’t my first time installing nextcloud (though it’s been over a year). I never had to create the users by hand in the past. What’s changed?

don’t know. my playbook is doing this way since 14 Feb 2018

but you are the second member here complaining that oc_admin is not created. which howto are you using? :wink:

This one:
which… you know, you’d hope was correct

Ok, so I did it and received the following error:

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’@‘localhost’ (using password: YES)

following that I tried mysql -u nextcloud -p and was able to access the server without issue.

OK. Here’s the poop:

I had a look at the MySQL.php code which does the user creating. I don’t know enough object oriented PHP but was able to see that it only attempts to create users if there isn’t a user identified in config.php. So I created the user as described in the above posts and created a config.php (in the config directory) with minimal configuration information. Just the database setting and user/password settings. Then after failing again (the list of PHP modules in the manual is incomplete) I was able to try yet again and it appears to have installed. I haven’t tried it yet, but hopefully everything is complete.

I was also able to run some PHP (on my own) to create a user in SQL and then use that user information to connect to a database… exactly what I suspect the installer is doing and everything worked great which seems to indicate that there’s nothing wrong with my environment. But I don’t actually know.

Do not use special characters in the password of the user nextcloud and YourNextcloudAdmin

1 Like

That works! I used the 1password to generate a strong password for the ‘nextcloud’ database, and it contains a lot of special characters.