Have you ever experienced or come across this error establishing a database connection issue before? I bet you, it is not funny at all. My first experience with this WordPress error was a terrible one. This happened when it was time to hand over the website to the company that owns it after designing. If you are a web designer, you know the implications. After several hours of research, I could not get any help but later found the cause and then the solution followed.
Here, I am going to outline some possible cause of this error and like steps you need to take to get it resolved as soon as possible.
Why this Error?
This probably should be the first question every victim should ask. While I cannot specifically tell you the reason you are seeing this error, I am going to list out the possible reasons why your website chose to display this unusual message. There are several reasons why this happens. When you observe this error carefully, you will discover that WordPress cannot access your database. Do you know how the database works? When setting up your WordPress site, the information you entered like your password, post, pages and other files like images and plugins are all registered and stored somewhere known as MySQL Database. Therefore, when your website or any of your posts are visited, WordPress helps you fetch the necessary information needed to load that post from the database.
Here are the reasons for the error:
WordPress Cannot Access Your Database.
This happens when your credentials are not properly entered into the wp-config file. The credentials are the database information WordPress requires in order to load your website. If the information is not correct, WordPress will be left to display that error message.
Your Database has been altered.
This problem particularly could occur as result of installing bad plugins. If this may be the cause of your problem, then don’t panic, it can also be fixed.
Your Hosting Server is down.
If the server hosting your account is down, it will definitely result to this error. And this kind of problem can be out of your control at-times because this may have occurred as a result of huge traffic coming to your website.
How to Fix it?
The cause of this problem (error establishing a database connection), would definitely fall under any of the categories mentioned earlier. Now let’s take the solution to this problem one after the other.
WordPress unable to access your database:
This is the most commonly known problem. To solve this, cross check the wp-config.php file and ensure your associated database details are entered correctly. The details include the database name, user name, password and host name. During my experience with this error, this is the cause of my error. The issue was that I incorrectly entered the database username. I failed to put the prefix before the user name which normally is separated by an Under Score. If after fixing this and you are still having issue then try using another browser to load your website.
Your Database May be Corrupt.
Another thing that could result to this error is your database being altered by external factors. A good example of this is installing improperly coded plugins. If this may the cause of your error, then try to run a database troubleshooting. To do this, paste this line of code to your wp-config file.
this code allows you to repair your database with a click of the mouse. After saving this file, type your website address in your browser along with this link at the front (wp-admin/maint/repair.php). e.g. http://mysite.com/wp-admin/maint/repair.php
A page like this one below should appear giving two options to repair your database.
After repairing your database, make sure you remove the line of codes you pasted earlier in the wp-config file for security reasons. If after troubleshooting, you are still faced with this problem then finally try the last step.
Your Hosting Server is down.
This issue has a better chance of being solved if you contact your hosting company for help. I seriously advise you to contact your hosting server for help if after trying our useful tips and you are still locked out of your website.
Always backup your site. In case something went wrong with your, you don’t have to start from scratch. Better be prepared than sorry. There are several plugins that can do that, and one of them is BackUpBuddy.
Where you able to fix this issue? Share your experience with other readers in the comment box, share the joy. Enjoy!