Lindy dB.18 Apr 2024Updated 18 Mar 2026WordPress2 min read

How to fix Error Establishing A Database Connection in WordPress

On this page

We will cover the most common cause of Error Establishing A Database Connection – misconfiguration of database access details in this guide.

Make sure that the following conditions are met:

  • The database name matches the existing database name
  • The username of the assigned database user matches the existing database username
  • The Password matches the one assigned to the specified database user
  • The specified user has access privileges to the site’s database.

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

1. Log into your cPanel and navigate to the File Manager menu

How to fix Error Establishing A Database Connection in WordPress

2. Navigate to the root folder for your WordPress installation.

3. Right-click on the wp-config.php file with the mouse button and select Edit or View option

How to fix Error Establishing A Database Connection in WordPress

4. The file should contain the name, username, and password of the database assigned to your WordPress installation:

wp-config.php MySQL settings block with the DB_NAME, DB_USER and DB_PASSWORD lines highlighted

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

5. Go to MySQL Databases in cPanel:

How to fix Error Establishing A Database Connection in WordPress

6. Carefully check if there is a database whose name fully matches the one specified in wp-config.php file

cPanel Current Databases list with one database name highlighted

7. Then scroll down and check the database username

cPanel Current Users list with one database user highlighted

8. Set the password to the one specified in the wp-config file

How to fix Error Establishing A Database Connection in WordPress

9. Lastly, it is necessary to make sure that the specified user has access privileges to the database:

Add User To Database form with the User and Database dropdowns and the Add button

10. Click on the All Privileges checkbox and apply the changes. Once done, you will get the message stating that MySQL User has been successfully added to the Database with all privileges

MySQL Databases Manage User Privileges page with ALL PRIVILEGES ticked and the Make Changes button

That's it!

Once the database, its username, and password have been changed to the correct ones, the Error Establishing A Database Connection error on your WordPress site should be fixed.

If you experience the same issue after performing the steps above, feel free to contact our support team for further assistance.

Host your WordPress site the easy way

Optimised WordPress hosting with one-click installs and automatic updates.

Avatar for Lindy dB.

Lindy dB.

The Author

Lindy brings over 7 years of experience in SEO, web development, UI/UX design, and marketing to the table, with a special focus on the hosting industry. When not geeking out over the latest digital trends, you can find Lindy buried in a good book or exploring worlds in video games.