1. Home
  2. Hosting & Servers
  3. Managed Wordpress Hosting
  4. WordPress – How to Fix Error establishing a database connection
  1. Home
  2. Presales
  3. WordPress – How to Fix Error establishing a database connection
  1. Home
  2. Hosting & Servers
  3. Managed Wordpress Hosting
  4. WordPress – How to Fix Error establishing a database connection
  1. Home
  2. Presales
  3. WordPress – How to Fix Error establishing a database connection

WordPress – How to Fix Error establishing a database connection

See an error like this on your WordPress site?

This error isn’t too difficult to fix.

Step 1 – Log into cPanel

Step 2 – Open the File Manager. If you see a pop up box, just click OK on any selection

Step 3 – Find and click on the domain/subdomain’s root folder. This will normally be the public_html folder however if you want to be 100% certiain (it can be different for addon and subdomains) 

Step 4 – Find the wp-config.php file, right click and select Code Edit

If you get this popup box, just click Edit

Step 5 – Take note of the below lines as they appear on your screen

Step 6 – Keep that window open (we’ll need 2 windows open for this), open a new cPanel window and find the MySQL Databases option



Step 7 – Take note of the database names. Note that if you have multiple databases that don’t match you may need to repeat step 8 onward through some trial and error till you find the correct/matching database.

Check that the database names match in both the wp-config file and the MySQL Databases section

If they don’t match, change the database entry in the wp-config file to match what’s in the MySQL Database section

Step 8 – Look at the Add User to Database section in MySQL Databases and the DB_USER and DB_PASSWORD entries in the wp-config file

Make sure that they match (the database user and name don’t have to be identical but what’s in both sections needs to match) and then hit the Add button

Step 9 – Select All Privileges and hit the Make Changes button down the bottom

Once the change completes press the Go Back option in the next screen

Step 10 – Look at the Database Password section in MySQL Databases and the DP_PASSWORD section in wp-config

Step 11 – Click the Change Password option for the correct database user

Step 12 – Set the database password to what is in the wp-config file, it’s easiest to copy/paste it (make sure not to include the ‘ ‘ so in this case the DB password is Q.t555Spy!  )

That should be it! If you find you’re still having trouble, choose the Repair Database option from the MySQL Databases menu to repair the database

If you’re still having trouble put through a support ticket and our team will have a look at it for you.

Updated on April 15, 2020

Was this article helpful?