How Do I Fix Database Connection Errors? Print

  • Database Connection Error, Error Establishing Database Connection, MySQL Fix, WordPress DB Error
  • 0

The "Error Establishing a Database Connection" is a common and critical WordPress error. It means WordPress cannot connect to the MySQL database where your content is stored. Here is how to fix it.

Fix 1: Check Your wp-config.php File (Most Common)
Sometimes the database credentials in this file get changed or corrupted.

  1. Access your site via FTP or cPanel File Manager.

  2. Navigate to the root folder (usually public_html) and find the file wp-config.php .

  3. Download a backup copy, then edit the file.

  4. Look for these three lines:

    php
    define('DB_NAME', 'database_name');
    define('DB_USER', 'database_user');
    define('DB_PASSWORD', 'database_password');
  5. Verify these are correct. If you are unsure, log in to cPanel, go to "MySQL Databases" and check your database name and user. You may need to reset the password.

  6. Save the file and reload your site.

Fix 2: Repair Your Database
Add this line to your wp-config.php file (just above the "That's all, stop editing" line):

php
define('WP_ALLOW_REPAIR', true);

Then visit: yourdomain.com/wp-admin/maint/repair.php
Click "Repair Database." Important: After repair, remove that line from your config file!

Fix 3: Check if the Database Server is Overloaded
Sometimes the MySQL server is just too busy. If you have confirmed your credentials are correct, wait a few minutes and try again. If the problem persists, contact BurjHost support.


Was this answer helpful?

« Back

Powered by WHMCompleteSolution