Fixing 'Error Establishing a Database Connection'

The "Error Establishing a Database Connection" message means WordPress tried to connect to its MySQL database and failed. Your site will be completely unavailable to visitors until the connection is restored. This error has a short list of causes, and most are straightforward to fix.

WordPress site card with a broken red connection to a MySQL database cylinder, plus a wp-config.php credentials card showing DB_NAME, DB_USER, DB_PASSWORD constants

Common Causes

  • Incorrect database credentials in wp-config.php
  • The MySQL server is temporarily down or overloaded
  • The database user has lost its privileges
  • The database itself has been accidentally deleted or corrupted
  • A corrupted wp-config.php file

Step 1: Check Your Database Credentials

The most common cause is a mismatch between the credentials stored in wp-config.php and the actual database credentials in cPanel.

  1. Log in to cPanel via clients.cyclebreezehost.com.
  2. Open File Manager and navigate to your WordPress root directory (usually public_html).
  3. Right-click wp-config.php and choose Edit or Code Editor.
  4. Locate the following four lines:
define( 'DB_NAME',     'your_database_name' );
define( 'DB_USER',     'your_database_user' );
define( 'DB_PASSWORD', 'your_database_password' );
define( 'DB_HOST',     'localhost' );

Now verify each value:

  • DB_NAME and DB_USER: Go to cPanel > MySQL Databases. Confirm the database name and the username assigned to it under Current Databases and Current Users.
  • DB_PASSWORD: Database passwords are not displayed in plain text after creation. If you are unsure, reset the password (see Step 2).
  • DB_HOST: This should almost always be localhost on shared hosting.

Correct any discrepancies, save wp-config.php, and reload your site.

Step 2: Reset the Database User Password

If you are not sure whether the password in wp-config.php is correct, reset it:

  1. In cPanel > MySQL Databases, scroll to the Current Users section.
  2. Click the username linked to your WordPress database.
  3. Enter and confirm a new password, then click Change Password.
  4. Update DB_PASSWORD in wp-config.php to match the new password.

Step 3: Verify the Database User Has Full Privileges

A database user that has lost the required privileges will cause a connection failure even with correct credentials.

  1. In cPanel > MySQL Databases, scroll to Add User to Database.
  2. Select your WordPress database user and your WordPress database from the dropdowns, then click Add.
  3. On the following screen, select All Privileges and click Make Changes.

Step 4: Check Whether the Database Exists

If the database was accidentally removed, it will need to be recreated and your site restored from a backup.

  1. In cPanel > MySQL Databases, look for your database under Current Databases.
  2. If it is missing, you will need to restore from a Softaculous backup (see Step 6 below).

Step 5: Repair the Database

If the database exists and credentials are correct but you are still seeing the error, the database tables may be corrupted. WordPress has a built-in repair tool.

  1. Open wp-config.php and add the following line before the /* That's all, stop editing! */ comment:
    define( 'WP_ALLOW_REPAIR', true );
    
  2. Save the file and visit yourdomain.com/wp-admin/maint/repair.php in your browser.
  3. Click Repair Database and wait for the process to complete.
  4. Remove the WP_ALLOW_REPAIR line from wp-config.php once done — leaving it enabled is a security risk.

Step 6: Restore from a Backup

If none of the above steps restore your site, a backup is the most reliable recovery method.

  1. Log in to cPanel and open Softaculous Apps Installer.
  2. Click WordPress, then Installations.
  3. Click the Restore icon next to your site and select a recent backup.

Preventing This Error in Future

  • Never edit wp-config.php directly on a live site without keeping a copy of the original.
  • Schedule regular backups through Softaculous so you always have a recent restore point.
  • Avoid deleting databases from cPanel without first confirming which sites use them.

If you are unable to resolve the error using these steps, contact CyclebreezeHost support at info@cyclebreezehost.com — our team is available 24/7 and can assist with database-level issues.