How to Fix ‘Error Establishing a Database Connection’ Caused by Inaccurate Login Credentials

No matter which platform you use to build a website, you are bound to meet some errors, especially if you’re a beginner. Some errors might be grievous and other not so much.

Today, we are going to disclose an easy way to fix a common yet daunting WordPress errors (after white screen of the death) that is “Error Establishing a Database Connection in WP”

Let’s see what this error actually is!

The “error establishing a database connection’ usually occurs when your WordPress website is not properly communicating to your database; it makes your website go down. Indeed, it happens when your site has no access to your database.

Let’s get a better understanding of this error. As you know, all of the information on your site, including login information, page data, meta information, plugin settings, etc. is saved in MySQL database. The only data which is not saved there are core files of your plugin and theme such as wp-login.php, index.php and media content such as video and images.

When a user visits your site, PHP implements the code on the page and queries the information from the database in search of a specific answer and then present it into the browser of a visitor.

This process is quite crucial for your site to stay up. However, for some reason, if this process does not complete, your users will be shown the ‘EEDC’ error.

As a web owner, it can be a scary situation for you if your website is down. For each second that your website is not working, you may lose the opportunity to generate leads, convert them and earn revenue.

This situation is more panic than it seems, but don’t feel anxiety Keep reading this guide until the end to learn how to fix it.

Some Common Scenario Causing the ‘EEDC’ Error

Well, there could be various reasons responsible for this error. However, some of the most common are:

  • One of the most possible reasons for this error is that your DB (database) login credential is incorrect.

Note – Your WP site has different login credentials to connect to MySQL database.

  • Perhaps your DB has gone corrupt. As there are numerous moving parts of a website- sometimes, when installing or deleting themes and plugins, DB may get corrupted.
  • Maybe there is a corrupt file in your WP installation. Sometimes, this can even happen because of hackers.
  • Problem with your server. There is a chance that something is not accurate on your web host end causing this error. Sometimes, too many users on the same server can cause this error.

Troubleshoot for First Scenario

If you want to go into the more in-depth, has presented few more options on How to Fix the Error Establishing a Database Connection Problem in WordPress.

You may use the following way, if inaccurate login credentials are responsible for the error establishing a database connection in WP.

Check With Your DB Login Credentials

Incorrect login credentials is a common reason for this error. Most of the time, it happens when users migrate to a new hosting provider, their old database credentials stop working. Apart from this, changing database names, resetting passwords can be other possible reasons.

The very first thing you need to do is, check your DB login credentials. The connection details of your site are located in the wp-config.php file and this file is located at the root of your WP site.

This file includes 4 important pieces of information that needs to be accurate for the successful connection.

You can access the wp-config.php file by accessing ‘File Manager’ via Cpanel of your web host. Now check all your values against those are on the server. Make sure all are accurate. If not, you need to change them.

To check the database name, you need to log into PHPMyAdmin, a feature in your CPanel dashboard. Here you can find your database name at the bottom. Next, compare database name against the DB_Name value.  If you don’t find any database listed, then this problem might be with the host server.

Click on your DB name to see the names of tables in the database. Next, click on ‘Browse’ to find the name and URL and other settings of your website. If it is available there and matching with your wp-config entry, it means you have the right database. In case, if the URL is right but your wp-config file is inaccurate, you need to change it to match with the right database.

The next step is verifying the username and password. It can be done in two ways.

Step 1:

Make a small .php file to see whether you are able to connect to the database with the credentials from wp-configuration into a new text file type.

Next, save this file to your WP directory, you may give it name: ‘connectiontest.php’. Next, type the file URL into the browser and try it. Now you will view either the connected successful message or unable to connect message. If you are not able to access your username and password then go to step 2.

Step 2:

If you can’t locate the username and password in the table, it is time to create a new username and password in the wp-options table. You can do this via MySQL databases.

Here you can simply create new username and password. Click on ‘create user’ and then find ‘add a user to database’. Choose the username and password and then click ‘add’.

Don’t forget to update changes in the wp-config file as well. If the error still persists then the problem could be the DB_Host entry in wp-config. Most of the time, it could be because of local host’. Contact your hosting provider or use tutorial offered by them. A good web host should be always available for your help.

Hopefully, this guide will help you resolve this error hassle-free.