Access denied for user 'username'@'localhost' (using password: YES)

Access denied for user 'username'@'localhost' (using password: YES)

by Nigel Singer -
Number of replies: 1

I have installed Moodle on one subdomain (via a Plesk package), it installed properly without any issues - using the moodle installation guide.

It needed to be installed on a second subdomain.  I created a new database for that domain, a new user, uploaded the software, ran the installer and then I get:

Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'train_user'@'localhost' (using password: YES) in 

/lib/dml/mysqli_native_moodle_database.php on line 79

I had look at this file in both the working installation and this, and they are exactly the same - which you would expect.  The two users set up (one for the working subdomain and this new install) all have the same settings; as does the database.

This warning also shows:

****************

Error: Database connection failed

It is possible that the database is overloaded or otherwise not running properly.

The site administrator should also check that the database details have been correctly specified in config.php

********************

I cannot update or check the config.php file as it gets created at this stage of the install, so it cannot be a config setting.  The database names/password in the database install form are exactly as enetered in the SQL database settings on the hosting.  

So I am not sure what else to check?
Average of ratings: -
In reply to Nigel Singer

Re: Access denied for user 'username'@'localhost' (using password: YES)

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I disagree with you that it cannot be a config.php setting. I disagree even more that you cannot check or update the config.php file. That wouldn't be much use if you couldn't.

Essentially, if this happens the username, password and hostname (localhost) don't agree with the GRANT you did after creating the database. I don't know anything about Plesk but I would review the username and password settings in the database setup against the contents of config.php (once you have worked out how to access it).
Average of ratings: Useful (1)