Unable to connect to database using a config.php file

Avatar
  • updated
  • Answered

I get the below listed error when connecting to database:

Database credentials are incorrect. SQLSTATE[HY000] [1045] Access denied for user 'site01_databaseuser'@'localhost' (using password: YES)

My config.php settings are:

$username = "site01_databaseuser";
$password = "password";
$host = "localhost";
$dbname = "site01_databasename";

Pinned replies
Avatar
anonymous
  • Answer
  • Answered

Thanks for getting in touch with us! I've edited your post to remove any easily identifiable database names for your security and privacy, replacing them with a generic 'site01'. 

In a situation like this, the most likely cause is a mismatch between the password listed in the config.php file and the password associated with the database user. 

  • Login to the associated cPanel
  • Go to MySQL Databases
  • Find the associated database user under Current Users and select 'Change Password'
  • Enter the password in your config.php exactly as it is between the quotation marks, then save the change by pressing 'change password'

That usually works! Often, the automatically generated password in config.php may not directly align with what the database is using. 

That said, if you run into any trouble, please don't hesitate to contact our 24/7 technical support team. 

Avatar
anonymous
  • Answer
  • Answered

Thanks for getting in touch with us! I've edited your post to remove any easily identifiable database names for your security and privacy, replacing them with a generic 'site01'. 

In a situation like this, the most likely cause is a mismatch between the password listed in the config.php file and the password associated with the database user. 

  • Login to the associated cPanel
  • Go to MySQL Databases
  • Find the associated database user under Current Users and select 'Change Password'
  • Enter the password in your config.php exactly as it is between the quotation marks, then save the change by pressing 'change password'

That usually works! Often, the automatically generated password in config.php may not directly align with what the database is using. 

That said, if you run into any trouble, please don't hesitate to contact our 24/7 technical support team.