The setting up a Database Connection error is one of those obscenities that can happen for several reasons. As a WordPress learner, it can be especially frustrating when it comes to itself without changing anything.
Note: Before making any database changes, make sure you have enough backups
Why do you get this error?
This error can be occur because WordPress is unable to establish a database connection. Why WordPress is unable to establish a database connection now. It may be that your database login credentials are incorrect or have been changed.
It’s possible that your database server is unresponsive. It may be that your database has been damaged. This error is due to some type of server error, but there may be other factors as well. See ways to solve this problem.
Problem occur for wp-admin
First of all, you need to confirm that you are getting errors in both side front end and back end(admin panel) of the site. If you found same errors on the both pages, then go to the next step. For example if you get a different error on admin panel, “one or more database tables may not be missing, you may need to repair the database”, then you will need to repair your database.
This can be doen by simply adding the following line to your wp-config php file.
Once you done this, you can see the settings by going to this page: (http://site_address/wp-admin/maint/repair.php)
Remember, the user doesn’t need to log in to use this functionality, when it is defined. This is because its main purpose is to repair corrupted databases, when the database gets corrupted, users cannot log in often, so when you are repairing and optimizing your database, then delete it from wp-config php file.
If this repair does not fix the problem, or if you have problems repairing, then continue reading this article because you can get another solution to work.
Checking the WP-Config file
WP-config.php is probably one of the most important files in your entire WordPress installation. This is where you specify WordPress details to connect to your database. If you have changed your root password or database user password, then you also need to change this file. First thing you should always check if everything is in your wp-config file (php file).
We can gamble for hours having won a little or lost a lot, while also being home to tuck the generic cialis kids in and read a bedtime story.
Remember that your DB_Host value cannot always be a local host based on host, it will be different for popular hosts like HostGator, Bluhost, Site 5, this is a local host. You can find other host values here.
Some people suggested that they fixed their problem by changing the local problem with the IP. It is common to see such an issue during running WordPress on the local server environment
For example, in MAMP, when the DB_Host value changes to an IP, it can start working
This IP address will be different for different web hosting services.
If everything in this file is correct, it is reasonable to say that there is something wrong at the end of the server.
Check your Web Host (MySQL Server)
Often, while keeping this error in mind, your site tends to withstand a lot of traffic while establishing a database connection. Actually, your host server can not load the load (especially when you are on shared hosting).
Your site will actually slow down and some users will also get the error, you should work best if you want to meet your hosting provider in phone or live chat and ask if your MySQL server is responsive or not.
For those users who want to test, if the MySQL server is running itself, then you can do a few things to check other sites on the same server if they have problems. If these also getting the same error, then there is definitely something wrong with your MySQL server. If you do not have any other site on this same hosting account, just go to your cPanel and access phpMyAdmin and connect to the database.
If you can connect, we need to verify whether or not your database user has sufficient permissions. Then you have to create a new file named tstconnection.php and paste the following code into it:
Be sure to change the username and password if it is successfully connected, it means that your user has sufficient permissions, and there is something wrong. Go back to your wp-config file to ensure that everything is correct.