如果仅更改了密码,并且您收到该错误,则意味着访问 Drupal 知道的数据库的密码也需要更改。默认情况下,它存储在 sites/default/settings.php 文件中。在该文件中查找类似于以下的代码。
$databases['default']['default'] = array(
'database' => 'databasename',
'username' => 'sqlusername',
'password' => 'sqlpassword',
'host' => 'localhost',
'port' => '3306',
'driver' => 'mysql',
'prefix' => '',
'collation' => 'utf8mb4_general_ci',
);
最重要的部分是前三行,特别是 password => 之后的部分,应该是实际密码。 (databasename、sqlusername 和 sqlpassword 是实际值的占位符。)
由于 Drupal 可以使用不同的 settings.php 文件,请检查站点目录中没有其他具有该文件名的文件。例如,如果 Drupal 安装在 https://www.drupal.org:8080/mysite/test/ 上,则在以下目录中搜索 settings.php 文件。
- 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/sites.php 文件的内容可以更改使用哪个 settings.php 文件。例如,对于以下 sites.php 文件,sites/example.com/settings.php 文件用于域 example.org、example.it 和 example.com。
$sites['example.org'] = 'example.com';
$sites['example.it'] = 'example.com';
$sites['example.com'] = 'example.com';