Few WordPress errors cause more panic than a blank page reading Error establishing a database connection. It means WordPress can’t talk to its database. The message is scary but the causes are limited, so let’s work through them.

1. Check your database credentials

WordPress stores the database name, user and password in wp-config.php at the root of your site. Open it in cPanel’s File Manager and confirm these four lines are correct:

define('DB_NAME', 'your_database');
define('DB_USER', 'your_user');
define('DB_PASSWORD', 'your_password');
define('DB_HOST', 'localhost');

On cPanel hosting, DB_HOST is almost always localhost. Compare the name, user and password against what shows in MySQL Databases. A mismatch here — often after a migration — is the single most common cause.

2. Confirm the database user has privileges

In MySQL Databases, scroll to Add User to Database and check the user is attached to the database with ALL PRIVILEGES. If it isn’t, add it. A user with no privileges can’t connect even with the right password.

3. Repair a corrupted database

If the credentials are correct, the database itself may be corrupt. Add this line to wp-config.php:

define('WP_ALLOW_REPAIR', true);

Then visit yourdomain.com/wp-admin/maint/repair.php and run the repair. Remove that line from the config file afterwards, because it’s accessible without logging in.

4. Rule out a down or overloaded database server

If everything above checks out, the MySQL service itself may be down or overwhelmed — often from a traffic spike or a runaway plugin query. This is where you’ll want us to look from the server side. Open a ticket and mention the exact time it started.

5. Test with a fresh database user

Still stuck? Create a brand-new database user in cPanel, give it a fresh password and ALL PRIVILEGES on the database, then update wp-config.php with the new details. This rules out a subtly corrupted user account.

Work through these in order and you’ll almost always land on the cause. Nine times out of ten it’s a credential mismatch after a move.

Was this article helpful to you?

admin

Leave a Reply

You must be logged in to post a comment.