Error Establishing Database Connection on your WordPress Sites

Are you a website owners and got the message “Error Establishing Database Connection” while surfing your own site on your browser? May be you will scared and I think some of you already faced this. It’s a great fear for the website owner, isn’t it? Error Establishing Database Connection is a type of problem or error that you may face on WordPress sites and it may happen with lots of reason. If you are facing this problem, don’t worry you are in the right place and this blog is very helpful to solve this issues yourself.

What might be the reason for this?

WordPress works on two medium, i.e. PHP and MySQL. PHP is coding part and MySQL is database part. If WordPress core fails to connect with database, this type of message will appeared. The possible reasons are:

  • Your data base login credentials have been changed or incorrect
  • Plugin or theme may causing the issue
  • May be your database is corrupted or some table are corrupted
  • The server that contains the files is down.

Generally, this are the reason for this type of issues.

What is the best solution for this issues?

If you are facing this issue, you need to try the below listed steps and one of the below listed steps will help you. Don’t worry, your website is going to be normal soon.

Checking plugin and themes

This type of problem generally not caused by the theme or plugins although that might be the reason. So, I recommend you to check by renaming the theme and plugin folders. You can’t deactivate the theme or plugins via dashboard, so you need to login to your cpanel, and go to your WordPress installation folder and rename the theme and plugin folder. If no any changed occurred on the error message on the browser, restore that changes name to original.
This steps seems pretty complex, so you might skip this steps on first. You can check directly from the send steps.

Repair your database

The chances of issues to be resolved is high in this steps. Many of the sites got resolved with this steps. So, follow this steps nicely. In this steps you again need to go to your cpanel or you can access the WP installation on your hosting via FTP. (File Zilla or something like that.)
In the root folder of WP installation, you will get wp-config.php file. Open your file via editor and add the below line of code,

define(‘WP_ALLOW_REPAIR’, true);

Save that file. After that you can go to this link ` www.yoursiteurl.com/wp-admin/maint/repair.php` Here yoursiteurl is your own site link.
After visiting this link, you will get the options to repair database. Click on repair database. Your issues may be solved by doing this.
Once the database is repaired, remove the above added line of code from that file.

Check database credentials

Your database and WP core are connected with each other via wp-config.php file. As the above previous steps you can find that file. Check the below things on that file.

define(‘DB_NAME’, ‘database-name’);
define(‘DB_USER’, ‘database-username’);
define(‘DB_PASSWORD’, ‘database-password’);
define(‘DB_HOST’, ‘localhost’);

Make sure the database name, username, password and host. You need the put the valid credentials of your database.

Check your hosting server

If the errors still remain even followed the above steps, you need to check your server. If your steps was fine, better to contact with the server provider.

If you can able to solve the issue with the help of this post, please write the comment below that the steps you followed so that other who read this post will be thankful for you. If your problem is not solved again, comment us below, we will provide you the best alternative solution based on your queries.

 

Written by