How to Fix "Error Establishing a Database Connection" in WordPress
This WordPress error means the site cannot connect to its MySQL database. Fix it by checking wp-config.php credentials and database status.
Fixing "Error Establishing a Database Connection"
This error means WordPress cannot connect to its MySQL database. It is usually caused by incorrect database credentials in wp-config.php or a database server issue.
Step 1 — Check wp-config.php Credentials
- Log into cPanel → File Manager
- Navigate to
public_html(or your WordPress folder) - Right-click
wp-config.php→ Edit - Verify these values:
define('DB_NAME', 'your_database_name');
define('DB_USER', 'your_database_user');
define('DB_PASSWORD', 'your_database_password');
define('DB_HOST', 'localhost');
Step 2 — Verify Database Credentials in cPanel
- cPanel → Databases → MySQL Databases
- Check that the database name and user exist
- Under Current Users, verify the user is assigned to the database with All Privileges
If the user is not assigned:
- Scroll to Add User to Database
- Select the user and database
- Click Add → grant All Privileges
Step 3 — Reset the Database Password
If you are unsure of the password:
- cPanel → MySQL Databases → Current Users
- Click the username
- Set a new password
- Update
wp-config.phpwith the new password
Step 4 — Repair the Database
If credentials are correct but the error persists, the database may be corrupted.
Add this to wp-config.php temporarily:
define('WP_ALLOW_REPAIR', true);
Then visit: https://yourdomain.co.ke/wp-admin/maint/repair.php
Click Repair Database. Remove the line from wp-config.php afterwards.
Step 5 — Check Database Server Status
Contact our support team — occasionally the MySQL server requires a restart. WhatsApp us at +254 733 338 989 and we will check server status immediately.
Still need help?
Our Kenyan support team is on WhatsApp — real people, not bots. We respond in under 15 minutes.