Last updated on

Getting the “Error Establishing Database Connection” page can be a frustrating experience. In most cases, this means your website files are not able to connect to the MySQL service, or the service is not running. The following article will explain how you can troubleshoot these types of MySQL issues.


There are three common reasons that can cause the message “Error Establishing Database Connection” to occur on your website.

  1. The login credentials in the configuration are not correct,
  2. the MySQL server is not running, or
  3. he database is corrupted, and in need of repair.

The following article will outline instructions on checking all three.

Checking the MySQL login credentials

If you have recently made any changes to the configuration, or installed WordPress, you can check the wp-config.php file to ensure the credentials match what MySQL expects. The credentials you would need to accomplish this are the host, the database username, the database users password, and the database name itself.

If you are not familiar with editing your files, then it would be recommended to contact your host, as they should have the information needed to help you with this step.

In this example, the credentials needed would be the following:
Database Name: database_name
Database Username: database_username
Password: database_password
Host: localhost

The easiest way to verify these credentials is to navigate to your hosts MySQL interface, and it should list the database with the attached user, as well as have a place to set the password. If you are not able to view the current password, you would want to set it to what is found within your wp-config.php file, to ensure that the credentials match.

Checking the MySQL server

If you have checked your MySQL credentials, and the problem persists, there may be an issue with your MySQL server. To check the status, you can use telnet to view the status of the service. The simplest way to do so would be running the following command:
telnet 3306
If MySQL is running, this should return output similar to the following:

If it is not running, the Connection will be refused
telnet: connect to address IP ADDRESS: Connection refused

Repairing your Database

The third most common reason for the “Error Establishing a Database Connection” is a corrupt database, which can be caused by a number of things. Some of the reasons include a server crash, or hardware failure as well as processed being killed while writing to the database. These crashes also depend whether you are using MyISAM or InnoDB, as MyISAM is more susceptible to corruption.


To correct this, you can simply add this line to your wp-config.php file:
define( 'WP_ALLOW_REPAIR', true );
Once you have added this, you can reload your website, and should see this message when visiting /wp-admin/

If editing your files is not something you wish to do, the following guide will show you how to repair your database within phpMyAdmin.

Repairing a database in phpMyAdmin

  1. Login to phpMyAdmin
  2. Choose the database you are working with by clicking on it in the left menu
  3. Underneath the database, select Check All to highlight all the tables above
  4. Using the menu on the right hand side of the Check All option, select Repair Table
  5. Upon completion, you will see the Success Message


Congratulations! Now you are familiar with troubleshooting the most common causes of the “Error Establishing Database Connection” message. If you are still receiving the error after attempting these steps, then it would be recommended to contact your host for further assistance.




   200+ Design Templates + 1 Kick-ass SuperTheme
   6 WordPress Plugins + 2 Essential Services

Everything you need to build and manage WordPress websites in one Central place.

Leave a Reply

Your email address will not be published. Required fields are marked *