This is not a big issue but sometime this may feels you frustrated while resolving. In this article we will let you know the all the possible reason and their solutions.
– Your database server is unresponsive, in other words mysql server stopped(mostly in your local system).
– You changed the your database login credentials but forgot to change it in wp-config.php file.
– If your website is on server then login to the cPanel and try to access the phpmyadmin. If it is opening then it is clear that database server is ON.
– If you are developing on your local system the access your phpmyadmin and login there. If you are able to login means database server is ON. If not then start the MySQL
– Now check dabase name, and login credentials you used to login to phpmyadmin with code present in wp-config.php file present in below image. If not correct then correct them.
After above steps your are done and in 90% cases database connection error would resolve.
Now let us see the rest 10% cases. In such cases you can see on you website’s front-end and back-end you are getting two different messages related to database connection failure. To resolve this follow the above mentioned steps and after that write the below code in wp-config.php file and save it.
Once done visit this url: http://www.YOURSITEDOMAIN.com/wp-admin/maint/repair.php
This page will allow you to repair your database without login. Yes, you read correctly, without login. That is why be remember to remove te above code from wp-config.php file once database repair done. To repair your database click on ‘Repair Database’. It may take few minutes depending upon the databse size. After that you are done and you must able to access your website.