Drupal PDOException: SQLSTATE[HY000] [1045] Access denied for user

Published on Author JFLeave a comment

You might get this error and you’ve lost your mind trying to understand why you updated the password, logged into MySQL successfully from the command line, but still can’t get Drupal to talk to the db?

PDOException: SQLSTATE[HY000] [1045] Access denied for user 'drupal_user'@'127.0.0.1' (using password: YES) in lock_may_be_available() (line 167 of /var/www/html/website.com/includes/lock.inc).

The clue is probably right here beneath your nose:

‘drupal_user’@’127.0.0.1

In your settings.php file you have this:

$databases = array (
 'default' =>
 array (
 'default' =>
 array (
 'database' => 'website_db',
 'username' => 'drupal_user',
 'password' => 'mypassword',
 'host' => '127.0.0.1',
 'port' => '3306',
 'driver' => 'mysql',
 'prefix' => '',
 ),

Note the host = 127.0.0.1. You did this avoid a lookup for ‘localhost’.

Now check MySQL. Can drupal_user attach via localhost or 127.0.0.1?

Either change your drupal host in settings.php to localhost or allow drupal_user access on 127.0.0.1.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.