When you are visiting any WordPress related blog then you may experience the error in establishing the database connection in WordPress.
You will have the information about the three things:
The working of WordPress is based on two essential parts:
There can be many reasons behind this message. But most of the time it is done by the corrupt database. It also occurs when there will be corrupt WordPress core files and having problems with your web host. The major reason behind this problem is the incorrect database configuration details in your wp-config.php file.
You can identify these problems and perform a test to isolate the problem.
The first thing to do when this message appears on the front end of your site then, check it down that you are getting the same error when you are trying to access your wp-admin dashboard. If the problem exists with that dashboard also then you can skip to the next step. You have done the eliminating of the problem as a potential cause,
If the message is not same as the above and something like this written in screen “ the database need to repair” then you can go with steps given below.
Step 1:
Just turn on the repair utility in the wp-conf.php file:
Before starting this process, we need to edit the wp-config,php file for your site. There is another step to do that:
The same address as the folder contains wp-admin and wp-content is where your wp-config.php file is actually located.
You will have to add the shortcode to the editing your wp-config.php.
Define( ‘WP_ALLOW_REPAIR’, true );
Before going further, save the changes you have made till now.
Quick links:
Step 2:
The running of the automatic database repair utility
After the adding of the code snippet given above you can now access the WordPress database repair tool on.
YOURDOMAIN.com/wp-admin/maint/repair.php
Just click on the repair database to start the tool. After the tool fixes all the problems, your site will be completely working again. Then you should return to your wp-config.php file and remove the code you have just added to the repair utility.
Before going on this step ensure that your database is not corrupted and also check that your database login credentials are working.
If somehow these data is not matching with the database credentials which you have created via your dashboard. Due to that WordPress will not be able to access your database. Just use notepad and write down this code.
</php
$link = mysql_connect(‘localhost’, ‘mysql_user’, ‘mysql_password’);
If (!$link) {
die(‘Could not connect: ‘ . mysql_error());
}
Echo (‘Connected successfully”;
Mysql_close($link);
?>
Just replace MySQL with mysql_password with the actual username and password. Then you have to upload that file to your website with the help of cPanel or by FTP.
YOURDOMAIN.com/databasecheck.php.
If “connected successfully” appears then your database credentials are working and just go to the next step.
But you have got a message saying access denied then there must be a problem with the database credentials.
Just go and create new database credentials for your WordPress site.
1. Go to my SQL database in cPanel:
Just keep in mind that your host is using the cPanel, just go and create the MySQL Database option in the dashboard.
2. Create a new user:
Just go to the MySQL and find the box to Add a New User, enter new username and password.
3. Just add a new user to the database:
After creating a new user, you can now go to the Add a User to a database option and add the user to your WordPress site database.
Use ALL PRIVILEGES on the next line.
4. Go and update the wp-congig.php file with the new database user:
Just to finish this process you have to go back to your site wp-config.php file and just update the DB_USER and the DB_PASSWORD.
If somehow all the above methods are not working to fix it then you should go with this one.
Just upload a fresh copy of WordPress to your site. It will not affect your existing content, plugins, and themes.
Just update the version of WordPress by going to wordpess.org.
All you need to do now is to extract the zip file and delete the wp-content folder along with the wp-config-sample.php file.
Also, read:
Upload the remaining file via FTP on WordPress. Just overwrite the duplicate files.
This will make none of your core files are corrupt, this will fix all the issue.
If somehow all the methods are failed and you may deal with some issues. Some of the hosting potential problems are:
Finally, if you are having such problems then you should go to the host customers care.
Now you are able to fix the error establishing a database connection message. Do share it on all the social media platforms. Let me know if there is some problem.
WordPress is the most used (CMS) Content Management System around the world as it gives…
Nowadays an author biography is so much more than an online trend especially when…
As it well said by Bill Cunningham “Fashion is the armor to survive the…
If you are willing to build a website for the coin market, then you…
Hey! Are you looking to make a website? Why not you should be planning that…
Let's talk about the coolest stuff for your WordPress website—live streaming! Imagine going live with…