What this problem looks like
This error appears when WordPress boots but MySQL rejects the connection. Common causes include wrong passwords after a host migration, expired database users, localhost vs 127.0.0.1 mismatches, and full disk space on shared hosting.
The message affects the entire site including wp-admin. Fix credentials and server access first before you touch plugins or themes.
Step 1: Check if the problem is your host
Before editing files, confirm MySQL is running. Many UK shared hosts post maintenance notices on status pages. A sudden sitewide database error often means server-side downtime, not a WordPress bug.
- Open your host status page or support dashboard.
- In cPanel, open MySQL Databases and confirm the database still exists.
- Check disk usage. A full partition stops MySQL from writing.
Step 2: Verify wp-config.php database settings
Open wp-config.php via SFTP or File Manager. Compare these four constants with the values in your hosting database panel.
define( 'DB_NAME', 'your_database_name' );
define( 'DB_USER', 'your_database_user' );
define( 'DB_PASSWORD', 'your_database_password' );
define( 'DB_HOST', 'localhost' );
Step 3: Reset the database user password
After migrations or security scans, passwords in wp-config.php and MySQL often drift apart. In cPanel MySQL Databases, change the user password, then update wp-config.php to match.
- Create or locate the database user in hosting.
- Assign the user to the correct database with ALL PRIVILEGES.
- Set a new strong password.
- Update DB_PASSWORD in wp-config.php and save.
Step 4: Test connection with phpMyAdmin or WP-CLI
Log into phpMyAdmin from hosting. If you can browse tables, credentials are valid and the issue may be corrupted tables or a wrong table prefix.
cd /path/to/wordpress
wp db check
wp db repair
Step 5: Check table prefix and corruption
If $table_prefix in wp-config.php does not match actual table names in MySQL, WordPress cannot find its options table. Confirm prefix matches, for example wp_.
In phpMyAdmin, select the database and run Check Table on wp_options. Repair if the status shows corruption.
When to stop DIY and hire help
If credentials are correct but the error persists, you may have deeper corruption or a host configuration issue outside wp-config.php. BugShield diagnoses database connection failures at a fixed price with direct developer chat.