How to Fix Error Establishing a Database Connection in WordPress

Quick Summary

The WordPress error “Error establishing a database connection” means WordPress cannot connect to its database.

Common Causes

  • Wrong database name
  • Wrong database username
  • Wrong database password
  • Wrong database host
  • Database user missing permissions
  • Database server issue
  • Corrupted database
  • wp-config.php misconfigured

Step 1: Check wp-config.php

  1. Log in to cPanel.
  2. Open File Manager.
  3. Open your WordPress folder.
  4. Find wp-config.php.
  5. Check these values:

DB_NAME
DB_USER
DB_PASSWORD
DB_HOST

Common DB_HOST value:

localhost

Step 2: Check MySQL Databases

  1. Log in to cPanel.
  2. Open MySQL Databases.
  3. Confirm the database exists.
  4. Confirm the database user exists.
  5. Confirm the user is assigned to the database.

Step 3: Assign User to Database

  1. Go to MySQL Databases.
  2. Find Add User to Database.
  3. Select the database user.
  4. Select the database.
  5. Click Add.
  6. Select All Privileges.
  7. Save changes.

Step 4: Reset Database Password

If unsure, reset the database user password and update wp-config.php with the new password.

Step 5: Repair Database

If WordPress database is corrupted, you may need database repair.

Create a backup before making database changes.

Common Problems

Problem: Website worked before and suddenly broke.
Solution: Check if database password or user permissions changed.

Problem: Error appeared after migration.
Solution: Check wp-config.php database details.

Problem: Error appeared after restoring backup.
Solution: Confirm the database was imported correctly.

Need Help?

Open a support ticket:

https://bill.cybrohost.com/submitticket.php

Was this answer helpful? 0 Users Found This Useful (0 Votes)