修改cPanel密码后Drupal网站访问被拒,如何解决?
Alright, let's break this down—this is a super common gotcha after updating cPanel passwords, and it's straightforward to fix once you know where to look. The error is telling you exactly what's wrong: Drupal is trying to connect to your database using an old, now-invalid password for the user xx@localhost.
Here's how to resolve it step by step:
1. Find Drupal's core settings file
Log into your cPanel account and open the File Manager. Navigate to your site's root directory (usually public_html), then go into sites/default. Look for the settings.php file—this is where Drupal stores all its database connection details.
Note: If you don't see
settings.php, you might need to enable "Show Hidden Files" in the File Manager's top-right settings menu.
2. Edit the database password in settings.php
Open settings.php with cPanel's built-in text editor. Scroll down until you spot the database configuration block—it will look something like this:
$databases = array ( 'default' => array ( 'default' => array ( 'database' => 'your_database_name', 'username' => 'xx', // Matches the user in your error message 'password' => 'old_outdated_password', // This is the culprit! 'host' => 'localhost', 'port' => '', 'driver' => 'mysql', 'prefix' => '', ), ), );
3. Update to your new password
Replace the value inside 'password' with your new cPanel password (since cPanel typically syncs MySQL user passwords with your account password). Make sure you type it exactly—database passwords are case-sensitive, so no extra spaces or typos!
4. Save and test your site
Save the changes to settings.php, then head back to your Drupal frontend and refresh the page. The error should disappear immediately if you entered the password correctly.
Bonus: Troubleshooting if it still doesn't work
If you're still seeing the error, double-check these in cPanel's MySQL Databases tool:
- Confirm the user
xxexists and is linked to your Drupal database - Verify the password you set for
xxmatches what you put insettings.php - Ensure the user has
ALL PRIVILEGESassigned to the Drupal database (Drupal needs full access to function properly)
That's it—this fixes this specific error 99% of the time. It's just a matter of syncing Drupal's stored database credentials with the new password you set in cPanel.
内容的提问来源于stack exchange,提问作者escaped_designer

