What is meant by the database?

The database is nothing but a storage location of your files which you can access for future use.

For the most of the blogger’s general face the problem of the database connections. As soon as you open the site or access any files you can see the message as error establishing a database connection.

Sony 123.2 cm (49 inches) Bravia KLV-49W672E Full HD Smart LED TV

In my blog post, I am going to readers a brief explanation of the following terms.

What does error establishing a data connection actually mean?
The reasons why this message appears when you open the websites.
What to do fix those errors in your WordPress websites.

Error Establishing a Database Connection:

For every WordPress based website, there are two main parts one is your files and the other is the database. The files include the WordPress software, themes, plugins and media uploads. The database contains the actual posts and pages. When the user visits your landing pages, the PHP files reach out to the database to display related information.

Reasons why error database connection appears:

The error establishing a database connection appears due to the following reasons.

A corrupt database i.e this message appears when your database had been corrupted or duplicated with some ids.
Incorrect configuration details in the wp-config.php file.
When your WordPress files are corrupted and also see when there are problems in web hosting.

Sony 101.6 cm (40 inches) Bravia KLV-40W562D Full HD LED Smart TV (Black)

How to fix the error establishing database connections for your websites?

Method 1: Fix the issue by the WordPress dashboard utility repair.

Whenever you find such issues front end of the site also check them by opening the wp-admin dashboard. To resolve the issue and repair the database connection you need to go to file manager. You need to edit the wp-config.php file by going there which is available in the root folder of your website. You can also find the wp-admin and wp-content in the same folder.

error establishing a database connection

We need to look the debug option whether it is set to true or false. If you keep debugging options set as true then you can see all the errors in your database files are displayed. Do Not update the files in the production, you need to test manually and then update them

join now in the wealthyaffiliate program and earn 23$ recurring affiliate bonus

You need to add the snippet code of the database repair and set it as true and save the changes. You can now access the database repair tool and click the repair database to run the tool. Once the tool completes the repair the site works very fine and then remove the snippet code you have added by going to the wp-config.php file.

define( 'WP_DEBUG', true );
define( 'WP_DEBUG', false );

Method 2: check the database login credentials

The thing you required to check is your login details if your database works fine. Your database login credentials are described in the wp-config.php file. Check whether the login credentials matched with the one you had created in the host dashboard.

error establishing a database connection

In order to test your database credentials are working or not you need to use the MySQL connect function. Create a file in the notepad with name database check.php and add the MySQL function here. Use the same username and password which you had used in the wp-config.php file.

error establishing a database connection

Then you need to upload this file to cpanel and run it. If you see it had connected successfully then there is no issue with the database credentials. Still, you find the same issue you need to add a new user to use the WordPress site.

error establishing a database connection

You can create a new user by going to the MySQL databases in cpanel. Create the database and then add the user to the database you want. You need to give the user ALL Privileges. You need to update the newly created user details in the wp-config.php file

error establishing a database connection

You must reupload the wordpress core files:

Next step is to see whether the WordPress core files are corrupted or not. You need to upload a new version of the WordPress where your content is not corrupted. Now you need to extract the zip file and delete the wp-content and the wp-config-sample files. To overwrite the duplicate files you need to upload the remaining file with the FTP.

Samsung 139.7 cm (55 Inches ) UA55MU6100 Ultra HD 4K Led Smart TV With Wi-Fi Direct.

Finally you need to check with the hosts whether your database server is down which might be a reason for the error establishing a database connection. If so speak to your wordpress host and resolve it.