We use cookies to ensure you can get the best experience on our site. If you keep using this site we assume that you agree to our use of cookies. Privacy Policy OK

How to Fix the Error Establishing a Database Connection in WordPress

by | November 12, 2018

The following tutorial provides detailed information about the Error Establishing a Database Connection message in WordPress, including meaning and a few possible methods to fix it.

What Does the Error Mean?

If you are a website administrator and own a WordPress Hosting account, you have probably come across the Error Establishing a Database Connection error at some point. The message itself is a bit generic and does not give enough information about the root cause of the problem. However, what it means is that WordPress is encountering a problem while attempting to connect to its associated database.

The image illustrated below will give you a better idea and understanding of the warning.

error establishing a database connection in wordpress

Below, we’ve compiled a list of known solutions to the database connection issue that every WordPress administrator and end-user may encounter.

Solution #1: Check the wp-config.php file

If you have recently performed changes to your MySQL database via your Database Manager (such as modifying the password of your database) or your hosting account has been moved to a different server, then you will need to update the file wp-config.php as well.

wp-config.php (also known as the main configuration file) is probably the most important file in every WordPress system. It stores essential and sensitive information regarding your blog, such as the database connection settings and the security keys.

error establishing a database connection in wordpress 2

Open up the configuration file (it should be located in the root directory of your domain/sub-domain name). Once in the editor, look for the following four variables in your PHP code:

  • define('DB_NAME')
  • define('DB_USER')
  • define('DB_PASSWORD')
  • define('DB_HOST')

Double-check all four variables defined in the code and ensure that they match the database settings available in your Database Manager.

error establishing a database connection in wordpress 3

Solution #2: Repair the database

There are times when a database may become corrupt or damaged. Database corruption usually occurs as a result of a faulty or badly configured WordPress theme or plugin.

If you happen to receive an Error Establishing a Database Connection error, you can try to resolve the issue by repairing the MySQL database associated with your WordPress instance.

Performing a database repair is seamlessly easy and can be done in four steps:

  1. Sign in to your AwardSpace account.
  2. Once logged in, navigate to the MySQL Manager page inside your dashboard.
  3. Locate the database that is linked to your WordPress site and click on the Options icon.
  4. Open the Management tab and press the 1-click Repair button.

error establishing a database connection in wordpress 4

Now that you’ve followed the above steps, it is time for you to test your WordPress site’s connectivity. If everything goes as planned, no further error messages should appear on your page and your website should display properly.

Related Posts
Gutenberg Tutorial: Keyboard Shortcuts Featured Image

Gutenberg Tutorial: Keyboard Shortcuts

Learning the various Gutenberg keyboard shortcuts is one of the best ways to improve your productivity in WordPress.

Speed Optimization

WordPress optimization is crucial for your website speed and performance. The performance of your website will in large part determine the number of...

How to Create WordPress Child Theme

WordPress is a highly customizable CMS. It is true that a lot of the changes that you can make depend on the theme that you’ve installed. On the other...

awardspace logo
Where Ideas Turn Into Websites