How to Fix the Error Establishing a Database Connection in WordPress

0
135

How to Fix the Error Establishing a Database Connection in WordPress

When you start using WordPress, you’re bound to encounter a number of errors, some grievous, other not so much. It’s inevitable; it can be your fault, at times systems break, someone fails at their job, natural calamities strike – anything could cause an error.

Even something as good as an increase in traffic can break your WordPress site, leaving you with an error and a bad taste in your mouth.

How to Fix the Error Establishing a Database Connection in WordPress

Now, just like any other human-made project, WordPress is susceptible to its share of errors, none of which is as baffling and strenuous as the “error establishing database connection” error. That’s because this error doesn’t come with details of what went wrong, despite that it can be caused by several things, which – of course – only adds salt to the wound.

If you have been surfing the web for a while, you have at least seen this error a few times. Error Establishing a Database Connection is one of those curses that could be caused by many reasons. As a WordPress beginner, this could be awfully frustrating

specially when it happened on its own without you changing anything. We ran into this issue yesterday on our own site. It took a little over 20 minutes to detect and fix the problem. While doing the research to find possible causes, we realized that there was no good article that covered everything. In this article, we will show you how to fix the error establishing a database connection in WordPress by compiling a list of solutions all in one place.

Why do you get this error

Well in short, you are getting this error because WordPress is unable to establish a database connection. Now the reason why WordPress is unable to establish a database connection can vary. It could be that your database login credentials are wrong or have been changed. It could be that your database server is unresponsive. It could be that your database has been corrupted. In our experience, majority of the times this error happens because of some sort of server error however there could be other factors as well. Lets take a look at how to go about troubleshooting this problem.

What Does “Error Establishing a Database Connection” mean

To give you an insider’s understanding of the “EEDC” error, we first need to break down WordPress into its two fundamental components.

WordPress is built using PHP (e.g. index.php, sidebar.php etc) and MySQL. PHP is in charge of all functions on your WordPress site (e.g. posting comments, retriving posts and pages etc) and MySQL is in charge of data storage.

For instance, when you type your URL in the address bar and hit enter, PHP kicks in, fetches and displays the contents of the homepage (index.php) from your MySQL database. Images, videos and such media are, however, stored in the wp-content folder, from where they’re retrieved by PHP

What Causes the Database Connection Error

While the error is pretty straight-forward, the error page unfortunately tells you nothing about the problems which cause it – something hopefully some WordPress guru will address in the future. The fact is, there could be a number of reasons why your database is inaccessible. Unless you’ve really been tinkering with your PHP and site settings, the common causes fall into one or more of these three basic categories.

1. Login Credentials

Your database requires two separate items authenticate any user, WordPress or otherwise. That’s your login name and password. If those credentials have been changed, your database can’t be accessed, and no info means no page.

2. Corrupt Database

It does happen, for several different reasons, from malware or bad plugins, to problems at your host server (hopefully a reputable host company will have things running again ASAP).

3. Corrupt Files

Sometimes a single php file can have internal errors, if for instance you’ve had some kind of malware or a bad plugin that doesn’t work quite like it’s supposed to. Sometimes it’s not the php but another file the php is asked to open as part of your page.

4. Server not Available

Sometimes the server just can’t be reached. It may be down for maintenance, overwhelmed with traffic and unable to support new connections. Maybe there is a problem with your ISP and Internet connection, or browser.

How to Fix the Error Establishing a Database Connection in WordPress.How to Fix the Error Establishing a Database Connection in WordPress.How to Fix the Error Establishing a Database Connection in WordPress.How to Fix the Error Establishing a Database Connection in WordPress

LEAVE A REPLY

Please enter your comment!
Please enter your name here