Short answer: Cross-reference DB_NAME, DB_USER, and DB_PASSWORD inside wp-config.php against cPanel MySQL Databases, ensuring the database user holds 'All Privileges'.
Restore communication between WordPress and MySQL by auditing wp-config.php credentials, checking database users, and fixing corrupted tables.
Before you start: Back up your site files and database and download the backup to your own computer. How to take a full backup
Quick reference
| Config File | public_html/wp-config.php |
|---|---|
| Required Variables | DB_NAME, DB_USER, DB_PASSWORD, DB_HOST (localhost) |
| Repair Tool | define('WP_ALLOW_REPAIR', true); in wp-config.php |
Quick diagnosis
| Scenario & Suspected Cause | Immediate Action & Remedy |
|---|---|
| Mismatched credentials in wp-config.php | Cross-check DB_NAME, DB_USER, and DB_PASSWORD between wp-config.php and cPanel MySQL interface. |
| Missing database user permissions | Navigate to MySQL Databases, assign user to database, and grant 'All Privileges'. |
| Corrupted MySQL database tables | Click 'Repair Database' in cPanel or append define('WP_ALLOW_REPAIR', true); to wp-config.php. |
| Max MySQL connections saturated | Review persistent queries and optimize database indexing to speed up connection release. |
Steps
- Check wp-config.php Credentials: Open
public_html/wp-config.phpin File Manager and inspect:DB_NAME: Ensure the full database name matches cPanel (including prefix, e.g.user_wpdb).DB_USER: Ensure the database user name matches cPanel (e.g.user_wpusr).DB_HOST: Must be set tolocalhost.
- Verify User in cPanel: Go to cPanel > MySQL Databases. Scroll to Current Databases and verify that your DB user is actually assigned to your DB with ALL PRIVILEGES.
- Reset Password: Under Current Users, change the password for the DB user, and paste that exact new password into
define('DB_PASSWORD', '...');inwp-config.php.
Troubleshooting and tips
- Corrupted Tables: If credentials are 100% correct, a table may be corrupted. Add
define('WP_ALLOW_REPAIR', true);towp-config.php, then visithttps://yourdomain.com/wp-admin/maint/repair.phpin your browser to run the automatic repair tool. Remove the line after repair.
Need more help? If you run into an error while following these steps, open a ticket with technical support and our team will look into it. Open a ticket