What does this error mean?
The message "Error establishing a database connection" means WordPress cannot connect to the MySQL database that stores your site's content, settings, users, and posts. This is a critical error that makes your entire site inaccessible.
Common causes
- Incorrect database credentials in
wp-config.php - The MySQL database server is down or unresponsive
- The database has been corrupted
- The database user does not have sufficient privileges
- The server has exceeded its resource limits
Step 1: Verify database credentials
Open wp-config.php in the root of your WordPress installation and check these four values:
define('DB_NAME', 'your_database_name');
define('DB_USER', 'your_database_user');
define('DB_PASSWORD', 'your_password');
define('DB_HOST', 'localhost');
Then verify these credentials are correct:
- Log in to cPanel.
- Go to MySQL Databases.
- Confirm that the database name listed in
DB_NAMEexists under Current Databases. - Confirm that the user listed in
DB_USERis assigned to that database with All Privileges. - If the password is wrong, click Change Password for the database user, set a new one, and update
wp-config.php.
Step 2: Check if the database server is running
If the credentials are correct but the error persists, the MySQL server may be down. You can verify this by:
- Trying to access phpMyAdmin from cPanel. If phpMyAdmin also fails to load, the database server is likely down.
- Contacting your hosting provider's support team to check the MySQL service status.
Step 3: Repair the database
If the database exists but may be corrupted, WordPress has a built-in repair tool:
- Add this line to
wp-config.php:
define('WP_ALLOW_REPAIR', true);
- Visit
https://yourdomain.com/wp-admin/maint/repair.php. - Click Repair Database (or Repair and Optimize Database for a more thorough fix).
- Once complete, remove the line from wp-config.php — leaving it enabled is a security risk.
Step 4: Check database user privileges
In cPanel, under MySQL Databases:
- Find the database user under Current Databases.
- Click the user to view privileges.
- Ensure All Privileges is checked.
- Click Make Changes.
Step 5: Check the DB_HOST value
Most hosting providers use localhost as the database host. However, some providers require a specific hostname or IP address. Check with your hosting provider if you are unsure.
If the problem persists
If none of the above steps resolve the issue, the server may be under heavy load or have exceeded its resource limits. Contact Telecu Cloud support for assistance.