How To Remove “Error Establishing A Database Connection” Message?
October 29th, 2015 | by Ravi Chahar || 6 Comments |
While running a website, due to one single mistake, you can break your website. When it comes to the database then people don’t really feel like playing with it. Creating a new user in the database can be done by not more. Some people face a problem by getting “error establishing a database connection” message at their WordPress website.
In this tutorial, I am going to tell you how to fix error establishing a database connection message? Many people ask about it and want to know the reason. I will tell you about it.
What Do You Mean By Error Establishing A Database Connection?
Your website is build up with two types of languages PHP and MySQL. You should know how it works? PHP codes are used to store every detail you need. But it can’t show the page until it connects with the database.
All the details are checked in the database before proceeding further. If all the credentials are good then you will see the results. An error will be shown if the connection with the database can be made.
Reasons To Get “Error Establishing A Database Connection” Message:
Basically, there are three reasons for showing this error message.
1 : Your database may be corrupted. If that’s the reason then you can repair it using WordPress only. WordPress can do it for you.
2 : The details you have entered in your “wp-config.php” file are wrong. That means the database name, password, host name may be wrong due to which you are seeing an error message.
3 : The last one is due to your Web hosting website. Sometimes your website may go down due to the slow server.
You Can Remove Database Connection Error:
All the three reasons have their own solutions. You can remove database connection error very easily.
1 : If your database is corrupted then you just have to write a simple code in your “wp-config.php” file and you are done. While opening your wp-admin if you get “one or more database tables are unavailable” then it means your database is corrupted.
To fix it you just have to add:-
After adding this code open this URL :-
Make sure that you replace “yourdomain” with your website’s name. A page will be shown to you asking to repair the database or to repair and optimize the database. Click at “repair and optimize database” and if the database is corrupted then it will be repaired.
Make sure that you remove the code after repairing the database. It is not safe for your website. Hacker can use it.
2 : If your login details are wrong then you have to check them and correct them. You can do it by searching your “wp-config.php” file in your file manager>>web root>>wp-config.php and you can edit this file. Search for login details in this file.
define( ‘DB_NAME’, ‘database_name’ );
define( ‘DB_NAME’, ‘username’ );
define( ‘DB_PASSWORD’, ‘database_password’ );
define( ‘DB_HOST’, ‘localhost’ );
Check all the fields and match them with your original details. If something is not same then correct it. Remember that DB_HOST may not always be “localhost”. But for most of the web hosting websites, it is localhost. You can ask it to your web hosting customer service.
3 : This is the last one to solve. When you use a shared web hosting then it is possible that you may face downtime. There are many websites running on the same host. It may create a problem with your website. Before talking to your web hosting company, you can check other websites running on the same web host.
To remove database connection error, you should talk to your web hosting. Just ask them to check your website. Maybe their MySQL server is down.
Have You Removed the “Error Establishing A Database Connection” Message?
I hope you have removed the errors. As I have explained there may be three reasons for this error message to show. It is very important to remove database connection error because you can’t open your website without fixing it.
Many people ask how to fix error establishing a database message? I hope those people have got their answer. If you still face any problem then I am here to help you.