How to Fix: Error Establishing Database Connection in WordPress

You have lots of useful information on your WordPress blog and people are looking for such useful content. But unfortunately, whenever someone tries to access your blog it shows an irritating error “Error Establishing Database Connection”.

How to Fix Error Establishing Database Connection In WordPress

Most of your blog users will start looking for an alternative blog and find the content they require somewhere else. So your rankings will start decreasing and the audience will be gone too. But how you can fix this error on your WordPress blog?

In this article, we have some possible fixes for this error that your readers might be facing. So let’s have a look at all the fixes along with the causes of this annoying error in your blog.

Poor Quality Hosting Service

The majority of the newbie bloggers prefer to go for cheaper hosting services, without being aware of the disadvantages of such hosting service they just choose any hosting service that is cheaper compared to others.

But when choosing such a hosting service you may encounter some common problems when working with WordPress. Error Establishing Database Connection is one of them. So instead of looking for cheaper ones choose the one who provides better hosting service and quality.

Invalid Login Credentials

WordPress uses PHP scripts to retrieve the information and other data of your blog directly from the database. But if you have provided wrong login credentials then the framework will suffer establishing a proper connection with the database.

For fixing this issue you will have to edit your wp-config.php file and update the accurate login credentials instead of the older ones. These are the information you have to look for and fix

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );
/** MySQL database username */
define( 'DB_USER', 'username_here' );
/** MySQL database password */
define( 'DB_PASSWORD', 'password_here' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

Inaccurate Hosting Information

Hosting information is one of the most important factors that are used to identify the location of the required files in your database. Most of the hosting services use the localhost for their root folder to access the important files easily.

However, if you have moved your WordPress site to another hosting recently then it is more likely the real cause of your problem. Because if your hosting provider is using a different annotation, you will have to change it manually.

Corrupted Database And Files

If your users are unable to establish a secure connection with the database on your blog then, A corrupted database or a collection of corrupted files might be the reason behind this error. So you will have to either remove these files or fix them.

The first method is to use the automatic database fix to see if WordPress can automatically fix the error or not. Simply open your wp-config file using C-PANEL or FTP client and add the following code in it.

define('WP_ALLOW_REPAIR', true);

Now visit the following link and click on the repair database to repair your corrupted database and files. If the problem persists then contact your hosting service provider’s customer support for further guidance.

https://www.yourwebsite.com/wp-admin/maint/repair.php

Your problem will be solved by the team of experts if your hosting provider has good customer support.

Like this Article? Share on Social

TwitterFacebookPin

Leave a Reply

Your email address will not be published. Required fields are marked *

  +  eighty eight  =  ninety