The MySQL database user name or password is invalid

I am sure that I have configured the MySQL database correctly, but there is still an error on the installation page: the MySQL database user name or password is invalid. He has created two OC users in MySQL

QQ截图20220817202430

In the second last input field below the password field, you have to enter the database name, instead of localhost.

Did you create a database for Nextcloud beforehand?

Here the needed steps from my personal notes:

mysql -uroot -p

Create database user:

CREATE USER ncdbuser@localhost IDENTIFIED BY 'ncdbpassword';

Create database:

CREATE DATABASE IF NOT EXISTS ncdb CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

Grant priviliges on the newly created database to the newly created database user:

GRANT ALL PRIVILEGES ON ncdb.* TO ncdbuser@localhost;
FLUSH privileges;
exit;

In my example I chose “ncdbuser” as the database user, “ncdb” for the name of the database and ncdbpassword as a password fot accessing the database. You can of course change the names to your liking and instead of ncdbpassword you should generate a secure password.

After you created the database, you can create your Nextcloud adminuser by entering the following to the setup wizzard:


admin user -> Choose a name for the Nextcloud Admin User
Password -> Choose a secure password

Data folder -> leave as is, unless you created a folder for your data at another location outside of the nextcloud folder

Database -> MySQL/MariaDB

Database user -> ncdbuser
Database password -> ncdbpassword
Database name -> ncdb
localhost -> localhost

I created the database and user configuration page for nextcloud, and the information is also correct. Every time I run the configuration page, nextcloud will create the “oc_xianqiurr” user in mysql, and then prompt me that the database user name / password is invalid

Did you grant privileges?

GRANT ALL PRIVILEGES ON nextcloud.* TO nextadmin@localhost;

i used :

GRANT ALL PRIVILEGES ON  *.* TO nextadmin@'%';

Sorry I’m not sure why it isn’t working then… Maybe the password you filled in is actually wrong? Did you copy & paste it?

Also, I’m not a database expert, but*.* and '%' should definitly not be needed in order for it to work. By using this command you grant nextadmin access to everything from anywhere with full permissions. You basically created another root user, which is not good security practice.

Now I have another problem. After I reconfigured nextcloud according to the instructions you gave me, there was a 503 problem. I reset the timeout of nginx. It seems that everything is normal. However, after I input the correct account password on the login page, I click the login button. The page will return to the login page again after a short time of loading, as if it had been refreshed, without any prompt :sob: :sob: :sob:

Logs I get

{"reqId":"Zv0peqbUxjCU8MwTaVi4","level":2,"time":"2022-08-18T05:49:42+00:00","remoteAddr":"112.250.112.2","user":"--","app":"no app in context","method":"GET","url":"/","message":"Could not detect any host in https:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36","version":"","data":[]}
{"reqId":"Zv0peqbUxjCU8MwTaVi4","level":2,"time":"2022-08-18T05:49:42+00:00","remoteAddr":"112.250.112.2","user":"--","app":"no app in context","method":"GET","url":"/","message":"Could not detect any host in http:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36","version":"","data":[]}
{"reqId":"Ficeav5Z58FUwJhyq4LY","level":2,"time":"2022-08-18T06:04:00+00:00","remoteAddr":"112.250.112.2","user":"--","app":"no app in context","method":"GET","url":"/","message":"Could not detect any host in https:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36","version":"","data":[]}
{"reqId":"Ficeav5Z58FUwJhyq4LY","level":2,"time":"2022-08-18T06:04:00+00:00","remoteAddr":"112.250.112.2","user":"--","app":"no app in context","method":"GET","url":"/","message":"Could not detect any host in http:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36","version":"","data":[]}
{"reqId":"4AHQkG7kqyI6B2Ua9Mgv","level":2,"time":"2022-08-18T06:04:45+00:00","remoteAddr":"112.250.112.2","user":"--","app":"no app in context","method":"POST","url":"/index.php","message":"Could not detect any host in https:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36","version":"","data":[]}
{"reqId":"4AHQkG7kqyI6B2Ua9Mgv","level":2,"time":"2022-08-18T06:04:45+00:00","remoteAddr":"112.250.112.2","user":"--","app":"no app in context","method":"POST","url":"/index.php","message":"Could not detect any host in http:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36","version":"","data":[]}
{"reqId":"4AHQkG7kqyI6B2Ua9Mgv","level":2,"time":"2022-08-18T06:05:49+00:00","remoteAddr":"112.250.112.2","user":"--","app":"appstoreFetcher","method":"POST","url":"/index.php","message":"Could not connect to appstore: cURL error 28: Operation timed out after 60000 milliseconds with 1359872 out of -1 bytes received (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://apps.nextcloud.com/api/v1/apps.json","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36","version":"24.0.4.1","data":{"app":"appstoreFetcher"}}

Sorry I’m not sure what the issue is here. Maybe Nextcloud was not able to create all the tables correctly in the database. Maybe you could drop the database and the database user and re-create them. You probably also have to delete the Nextcloud folder and extract it again from the zip file you downloaded, in order to get the setup screen again.

But the error could also lie somwhere else… Webserver configuartion? Missing PHP modules? Check the Nextcloud docs for reference: Installation on Linux — Nextcloud latest Administration Manual latest documentation

If you can’t figure it out, I would recommand to start over on a clean system. if you are on Ubuntu or Debian, I can recommand this guide: Nextcloud: Full Setup & Implementation Guide – Learn Linux TV

This doesn’t look like it was resolved, and I’m running into the same issue. I’m noticing that the installer seems to generate its own password instead of using the one I’m setting on the form. when I check the config.php file, the dbpassword set in there is completely different from what I entered in the form. Every time I retry, the value in the config file changes to a different value, but never the one I use in the form. It seems like it’s got something set to autogenerate a password instead of using the form value. Note that while I generated a random password for the user, It’s set in mysql, and I confirmed I can login with that password. So I’m posting the same value in the form every time I submit& it comes out different on the config file every time.

EDIT:
I ended up working around it by forcing the password in the config.php file & using occ to do the install.