In this tutorial, I’ll explain how you can fix Error establishing a Database Connection on WordPress easily and for beginners.
The Error Establishing a Database Connection is a common issue for WordPress websites, this error occurs when a site refuses to the WordPress Database.
Most times, you may encounter this error after migrating a WordPress Website, let’s begin by understanding how WordPress Works…
WordPress is written in PHP and uses MySQL as the database system, so, MySQL stores all the information that makes up your website.
When someone visits your website, specific PHP comments will help get your Site’s information from the database and display it on the visitor’s browser.
If your PHP Comments could not come back to display your site’s information, The Visitor’s browser will display an Error Establishing a Database Connection Message.
Fortunately, this error message is not visible on the frontend, given that you’re using sold WordPress Cache Plugins but it blocks you from logging in to your WordPress Dashboard.
It’s essential to determine the cause of the issue and fix it right away…
Main Reasons Why Your Site Can’t Establish a Database Connection
- Your Database Login Credentials are incorrect.
- Your Database Server is down
- Or some of your WordPress Core files are corrupted.
Now that we’ve listed the common problems why your site may be displaying an Error Establishing a Database Connection Message, let’s talk about the common solutions.
4 Common Solutions to Fix Error Establishing a Database Connection
Match the Database Login Credentials
The first thing to do when experiencing this error is to check whether the database login settings match the ones in your wpconfig.php file which is your WordPress Website’s Configuration
To edit the wpconfig.php files, you’ll either have to go through FTP or File Manager, I prefer File Manager because it’s faster.
If you’re hosting your website with Hostinger, finding the File Manager is a piece of cake.
Simply log into your CPanel account and then you’ll thee the Files Section, open File Manager, and then open the public_html you should see the wpconfig.php, right click on it, and then click on edit.
You should find the lines of PHP code where the database name, username, and host are mentioned, then make sure they match with the information under your MySQL database user and host, if not, edit those lines of code and make sure that they are a match.
This is what the codes look like:
Make Sure that your Domain is pointing to your hosting Provider
You should make sure that the domain name of your website is pointing to your current Web Host. Use a WHOIS Lookup Tool and your hosting’s control panel to check the nameservers.
If you notice that your domain isn’t pointing to your Web Host and you’re having trouble editing your Nameservers on your Domain Registrar’s site, contact support on both ends (web host and domain registrar).
Check your Database Server
Most Web Hosts may offer you unlimited bandwidths and all that but that isn’t the case after they’ve received your money.
You may notice an ‘Error Establishing Database Connection’ message on your website if your MySQL server is down probably because it has reached its maximum capacity.
Fix Corrupt WordPress Files
This is what exactly caused my first website to start displaying an Error Establishing Database Connection Message and I did well to fix it in a few minutes.
Starting with my first WordPress Website, I didn’t want to pay for themes and plugins, I rather search for nulled versions and install them on my site.
If you’ve been doing so, you should stop because these nulled plugins and themes may contain malware and may also serve as a backdoor to scammers who are looking to exploit your website for backlinks or any other stuff.
To exploit your site, these hackers add certain codes to these nulled themes and plugins so that when you install and activate them, they’ll head over to your Database and create an account for the hackers.
There may be other tricks but either way, nulled plugins and themes can get to your WordPress Database and cause the Error Establishing Database Connection issue.
If you start a blog on a tight budget, start with a free theme and plugin(s), then when you’ve made some affiliate or ad revenue, you can purchase premium themes and plugins from Themeforest.
Before you Install or Update any WordPress Theme or Plugin(s), you should backup your WordPress Website and I’ve got just the resources you need:
I believe that after reading this article, you must have been able to fix the ‘error establishing database connection’ issue on your WordPress Website.
If you have any questions whatsoever on the topic, do well to ask me in the comments below, and don’t forget to share this article, to support this site.