This error means WordPress loaded but couldn't connect to its MySQL database. It's almost always one of four things: wrong database credentials in wp-config.php, a database that's been corrupted, a database server that's down, or corrupted core files. Work through them in this order.
1. Check Your Database Credentials
Open wp-config.php in your site's root folder and confirm these four values match what's actually set up on your hosting account:
define('DB_NAME', 'your_database_name');
define('DB_USER', 'your_database_user');
define('DB_PASSWORD', 'your_database_password');
define('DB_HOST', 'localhost');
In cPanel
Log into cPanel and open MySQL Databases to confirm the database name and username exist exactly as written, including any account-specific prefix. If you're not sure of the password, reset it from the same page and update wp-config.php to match.
In DirectAdmin
Log into DirectAdmin and open MySQL Management to confirm the database name and username. Reset the password there if needed and update wp-config.php to match.
A mismatch here, often from a recent migration or a changed password, is the most common cause of this error.
2. Check Whether the Database Server Is Reachable
If your credentials are correct, the database server itself may be temporarily overloaded or down. This is more likely on shared hosting during high-traffic periods. Wait a few minutes and reload the page. If the problem persists, contact your host to check the database server's status.
3. Check for a Corrupted Database
If WordPress loads the login screen but shows this error only on certain pages, or shows a message about "one or more database tables are unavailable," the database itself may need repair.
- Add this line to wp-config.php:
define('WP_ALLOW_REPAIR', true); - Visit yoursite.com/wp-admin/maint/repair.php in your browser.
- Click Repair Database and let it finish.
- Remove the line from wp-config.php once done, this page is otherwise publicly accessible to anyone who knows the URL.
4. Check for Corrupted Core Files
If none of the above resolves it, the WordPress core files themselves may be damaged, sometimes from an interrupted update. Re-upload a fresh copy of WordPress core files (everything except wp-content and wp-config.php) from a clean download, which replaces any damaged files without touching your content or settings.
Always back up your database before running a repair or replacing core files. It's a low-risk operation, but it's not one to attempt without a fallback if something goes differently than expected.