Braysons Host logo
Order NowGet Started Free
Troubleshooting

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.

5 min read
Updated 20 August 2026

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

  1. Log into cPanel → File Manager
  2. Navigate to public_html (or your WordPress folder)
  3. Right-click wp-config.phpEdit
  4. 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

  1. cPanel → Databases → MySQL Databases
  2. Check that the database name and user exist
  3. Under Current Users, verify the user is assigned to the database with All Privileges

If the user is not assigned:

  1. Scroll to Add User to Database
  2. Select the user and database
  3. Click Add → grant All Privileges

Step 3 — Reset the Database Password

If you are unsure of the password:

  1. cPanel → MySQL Databases → Current Users
  2. Click the username
  3. Set a new password
  4. Update wp-config.php with 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.

Tags:database errorWordPressMySQLwp-config

Still need help?

Our Kenyan support team is on WhatsApp — real people, not bots. We respond in under 15 minutes.

WhatsApp Us
Braysons Host — Kenyan Hosting with WhatsApp Support