Error creating admin account

I followed the instructions to install Nextcloud manually. All worked fine untill the installation wizard. I also tried the command line installation but i get the same 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 ā€˜oc_kpwnā€™@ā€˜localhostā€™ (using password: YES)

I did make an extra admin user with a normal password for maria db. The user is granted all rights to everything. Logging in to SQL works fine with the Username and password. Yet the nextcloud installation wizards fails. I tried all the solutions (there are all more or less the same, create extra user with admin rights)

The only slightly ā€œunusualā€ thing about my installation is that my datadir for Mariadb is not in the standard path. But like i said MariaDB itself works.

1 Like

which sql commands did you use to create the user and database?

ā€œcreate databaseā€ for the database

CREATE USER ā€˜sqladminā€™@ā€˜localhostā€™ IDENTIFIED BY ā€˜passā€™;
GRANT ALL PRIVILEGES ON . TO ā€˜sqladminā€™@ā€˜localhostā€™ WITH GRANT OPTION;

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
CREATE DATABASE IF NOT EXISTS nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT ALL PRIVILEGES on nextcloud.* to 'username'@'localhost';
FLUSH privileges;

https://docs.nextcloud.com/server/17/admin_manual/configuration_database/linux_database_configuration.html#configuring-a-mysql-or-mariadb-database

I tried it, same result.

Error message:
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 ā€˜sqladminā€™@ā€˜localhostā€™ (using password: YES)

which command did you use here? (occ ā€¦)

sudo -u www-data php occ maintenance:install --database ā€œmysqlā€ --database-name ā€œnextcloudā€ --database-host ā€œlocalhostā€ --database-port ā€œ3306ā€ --database-user ā€œsqladminā€ --database-pass " **** " --admin-user ā€œadminā€ --admin-pass " **** "

of course * is just to hide the passwords.

just a guess: try without --database-port ā€œ3306ā€

I akready tried ommitting that field. No difference

but you are able to connect via mysql command?

Des thats works just fine. As the new user and as root.

last idea: funny charaters in the password?

you could try the php code on this page:

https://www.w3schools.com/php/php_mysql_connect.asp

1 Like

Good guess! That was a problem before but i solved that quickly. The passwords now are long, but only contain upper and lowercase letters. I will check the site.

I tried the php code on that page to use PDO to connect to my mariaDB it works just fine.

I also verified the downloaded nextcloud files. They are ok too. Maybe a useful error message would help, but as usual that is too much to ask for.

apache is also serving other pages which all workā€¦

according to nextcloud.log there is either a wrong password or an sql syntax error. The password is correct since i copied it.
Anyone knows where the php script sits that is executed during installation?

Exactly, thank you!After removing the backslash charakter, it worked perfectly!