0
votes

My colleague changed a cPanel password for a Drupal site. The front-end is now displaying the following error.

Error
The website encountered an unexpected error. Please try again later.

Error message PDOException: SQLSTATE[HY000] [1045] Access denied for user 'xx'@'localhost' (using password: YES) in lock_may_be_available() (line 167 of /home/xx/public_html/includes/lock.inc).

How do I fix this error?

1

1 Answers

0
votes

If only a password was changed, and you get that error, it means the password to access the database that Drupal knows needs to be changed too. By default, that is stored in the sites/default/settings.php file. Look for code similar to the following, in that file.

 $databases['default']['default'] = array(
   'database' => 'databasename',
   'username' => 'sqlusername',
   'password' => 'sqlpassword',
   'host' => 'localhost',
   'port' => '3306',
   'driver' => 'mysql',
   'prefix' => '',
   'collation' => 'utf8mb4_general_ci',
 );

The most important part are the first three lines, in particular what follows password =>, which should be the actual password. (databasename, sqlusername, and sqlpassword are placeholders for the real values.)

Since Drupal can use different settings.php files, check there aren't other files with that filename in the sites directory. For example, if Drupal is installed on https://www.drupal.org:8080/mysite/test/, the settings.php file is searched in the following directories.

  • sites/8080.www.drupal.org.mysite.test
  • sites/www.drupal.org.mysite.test
  • sites/drupal.org.mysite.test
  • sites/org.mysite.test
  • sites/8080.www.drupal.org.mysite
  • sites/www.drupal.org.mysite
  • sites/drupal.org.mysite
  • sites/org.mysite
  • sites/8080.www.drupal.org
  • sites/www.drupal.org
  • sites/drupal.org
  • sites/org
  • sites/default

Then, the content of the sites/sites.php file can change which settings.php file is used. For example, with the following sites.php file, the sites/example.com/settings.php file is used for the domains example.org, example.it, and example.com.

$sites['example.org'] = 'example.com';
$sites['example.it'] = 'example.com';
$sites['example.com'] = 'example.com';