How to Fix the Error Establishing A Database Connection in WordPress

If it is your first time to use WordPress, you are most likely to come across numerous errors; some of these errors are serious, while some are not. It’s normal, you cannot avoid it; you can be at fault, there are times that systems unexpectedly break, others may be failed in their job – actually, anything could cause a sudden error.

Now, in a similar way as some other human-developed projects, WordPress is vulnerable to lots of errors, and there is no error that is as inexplicable and as demanding as the famous “ERROR ESTABLISHING DATABASE CONNECTION” error. This is for a reason that this certain error does not come in details of what really went wrong on your website.

Error Establishing Database Connection is an error that could be caused by so many reasons, thus making it a curse to WordPress users. As a first timer in WordPress, it could horribly be annoying most especially when this occurs on its own without you doing anything on it.
In this article, we will demonstrate to you how to fix this frustrating ERROR ESTABLISHING DATABASE CONNECTION error in WordPress.

“ERROR ESTABLISHING DATABASE CONNECTION,” what does this mean? To provide you a clear explanation on how devastating this error is, let us first take a look on how does WordPress display your website.

WordPress is constructed via Hypertext Preprocessor (PHP) and MySQL. Maybe you are asking why is there two different languages? This is mainly because all information that composes your website is being stored and saved in a MySQL database, and PHP serves as the retriever of that stored information in the database.

Your created MySQL database includes all the very important information PHP needs to make your website. Thus, if PHP cannot gain access to your MySQL database for any reason, you get the frustrating message: “error establishing database connection” on your screen.  It implies that for some cause the PHP code cannot connect with your MySQL database to retrieve the information it needs to build a certain page.

What causes this EEDC?

There are many reasons why your website could not connect to your MySQLO database, but they normally fall into these categories: Incorrect login credentials. Your MySQL database uses separate login details. If those login details have been changed, most probably, your website won’t be capable of accessing your MySQL database with the old credentials.

Corrupted MySQL databse. Alot of things such as Bad plugins, addons, themes and other interruptions could cause your MySQL database to corrupt.

Database Server is unresponsive. The database server of your MySQL database may be dead due to a problem or there could be a big traffic spike that your server couldn’t handle.

Troubleshooting the EEDC error

Here are some tips that you can use to restrict the problem and fix it.

1.Find out where the error occurs

The first thing you need to do is to determine where this error occurs in your website.
Good thing WordPress has created a built-in method if you want to try repairing your MySQL database. Firstly, you need to enable this feature; you will have to access your wp-config.php file, this file restrains your WordPress’ setting on installation and configuration.
You can look at it in your WordPress file directory; you need to login first in your cPanel, select File Manager, and then navigate through the folder where you installed WordPress.

Once you’ve opened the wp-config, add this code in the bottom part: define( ‘WP_ALLOW_REPAIR’, true ); This code will then allow you to optimize and repair your MySQL database.

This screen will then pops out. It contains the two options: Repair Database and Repair and Optimize Database. It is your call on what choice you will choose. However, it is right to know that it takes longer if you choose to optimize your database.

If you still see the error after doing the said method of repairing the database, perhaps the error is from incorrect login credentials, corrupted WordPress files or an impassive database server.

2. Verify login credentials in wp-config

To check your MySQL database login details, you must first open your wp-config.php then look for this line of codes:

As you can see in the above image, it shows the four pieces of information that is really needed by WordPress to access your MySQL database:
The name of your database (“DB_NAME”)
Your login username (“DB_USER”)
Your login password (“DB_PASSWORD”)
Your database host (“DB_HOST”)

If any of these for values is wrong, WordPress will not be connected to your database. At this moment, you need to counter-check all your login details besides those details that you saved in your database.
Moreover, if you want to check your MySQL database outside the WordPress, you can use PhpMyAdmin., a means for editing and accessing MySQL databases. It is integrated in most of the hosting plans and is located in the cPanel dashboard. However, you should be careful in using this tool because you’ll be dealing directly with your site’s database.

3. Check with your hosting company

If you still get the annoying EEDC message, might as well contact your web hosting company and give them all the important details about the error and all the actions that you’ve done to troubleshoot it. They may help you in determining what really causes this error.

4. Fix Corrupted WordPress Files

There are some instances that the EEDC error was caused by the corrupted files from your WordPress website. In this event, you don’t need to worry that much because you could resolve this by simply restoring your WordPress files. However, a safety precaution must be taken. It is a must that you have to be careful because a single mistake can cause a big trouble to the totality of your website. You should make a back-up of your entire WordPress website in case you will create a mistake in the process.

Ultimately, you should not be frustrated when you come across this error. It is really simple to solve it, and you should not worry too much because your web hosting company is always just at your back. Just one call, and the help you need will be given to you.

How to Fix the Error Establishing A Database Connection in WordPress
2.9 (58.91%) 128 votes

Leave a Reply

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