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.
The message affects the entire site including wp-admin. Confirm database credentials and that MySQL is reachable before you change plugins or themes.
Step 1: Check if the problem is your host
Before editing files, confirm MySQL is running. A sudden sitewide database error often means the database server is down or unreachable, not a WordPress bug.
- Check your hosting dashboard for MySQL or database service alerts.
- 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. It usually sits next to the wp-admin and wp-content folders. 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 your hosting panel’s database tools, change the database 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_PASSWORDinwp-config.phpand 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.
If your host offers SSH or terminal access, you can also check and repair the database with WP-CLI from the WordPress root. These commands need server access. If you only have a hosting control panel, stay with phpMyAdmin for browsing tables and running Check Table / Repair Table from there.
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 the prefix matches, for example wp_.
In phpMyAdmin, select the database and export a full backup first (SQL or gzipped SQL). Keep that file somewhere safe, then run Check Table on wp_options. Repair only 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 confirmed price without hourly billing surprises.