How to Fix the Error Establishing a Database Connection in WordPress

3 min


How to Fix the Error Establishing a Database Connection in WordPress
How to Fix the Error Establishing a Database Connection in WordPress

How to Fix the Error Establishing a Database Connection in WordPress

What Causes Error Establishing a Database Connection in WordPress?

The “error establishing a database connection” is probably one of the most common and frightening errors that WordPress users can encounter. This error means your website is no longer communicating or has access to your WordPress database, and thus your entire website goes down. This is not something to be taken lightly and you should try and resolve this immediately as this can directly affect your sales, traffic, and analytics.

But don’t worry, today we’ll discuss How to fix Error Establishing A Database Connection.

Error establishing a databaseconnection message

The ‘Error establishing a database connection’ issue can be caused by incorrect database information in your WordPress settings, corrupt database, or an irresponsive database server.

As a content management system, WordPress uses a database to store all your content and other website data. It then connects to the database each time someone visits your website.

So that you have to check following details,

  • Database name
  • Database username
  • Database password
  • Database server

Make sure that the following conditions are met,

  • Database name matches the existing database name
  • Username of the assigned database user matches the existing database username
  • Password matches the one assigned to the specified database user
  • Specified user has access privileges to the site’s database.
1. Check Your WordPress Database Credentials

Database name, database username and its password can be found in the wp-config.php file located in the root directory of your WordPress installation. In order to check these details, do the following,

  • Log into your cPanel and Click on File Manager. Move to the root folder for your site, WordPress installation.
  • Click on the wp-config.php file with the right-mouse button and select Edit or View option.

cPanel file manager edit config

Once you have found the database details in the wp-config.php file, the next step is to check if they are correct.

wpconfig set details database

2. Check your MySQL Databases in cPanel

MYSQL database cPanel

In cPanel click on MYSQL Databases and Carefully check if there is a database which name fully matches the one specified in wp-config.php file. If not check the all details which one matches or handle WordPress site.

mysql database

Then scroll down and check the database username.

user change password

3. How to Fix the Error Establishing a Database Connection in WordPress

 

Error establishing a databaseconnection message

Now you need to make sure that the information for the database name, username, password, and database host is correct.

  1. Check data base name matches to (wp-config.php) database name
  2. Check data base username matches to (wp-config.php) database username
  3. Check data base password matches to (wp-config.php) database password
  4. Check data base host matches to (wp-config.php) database host
So that let’s change the password of the MYSQL User.

Find the user who handle your WordPress site then change the password.

user change password

Set New password.

set password for mysql user

Select all and Click on Make Changes.

user privilegs for mysql database

Now set the all details in wp-config.php file. Make sure that the information for the database name, username, password, and database host is correct.

If you have any problem click here to get support from TechEdutricks Community.


Like it? Share with your friends!

Danushka Sanjeewa
Danushka Sanjeewa is a Software engineer with more than 5 years of experience in Android App Development, Web Development, Marketing, Graphic design, Video editing, and WordPress. And also Writer/Founder of TechEduTricks.com.

0 Comments

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