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.

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

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?