How to Fix the Error Establishing a Database Connection in WordPress5 min read
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.
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.
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:
Double-check all four variables defined in the code and ensure that they match the database settings available in your Database Manager.
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:
- Sign in to your AwardSpace account.
- Once logged in, navigate to the MySQL Manager page inside your dashboard.
- Locate the database that is linked to your WordPress site and click on the Options icon.
- Open the Management tab and press the 1-click Repair button.
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.