Error establishing a database connection WordPress solution

Error establishing a database in WordPress is a common problem.

I’ve been using WordPress for more than 13 years now and I still love what it can do. Using this hugely popular CMS, it is relatively easy to throw up a good looking website in a matter of hours. But even though I consider myself a WordPress guru, it also sometimes drives me absolutely crazy. The error establishing a database connection WordPress problem is a good example of an issue I have experienced many times over the years. So rest assured, you are not alone!

What causes the error establishing a database WordPress problem?

Ninety-nine percent of the time, this error is due to an incorrect WordPress database username or password. It is very easy to enter in your username or password incorrectly so you really need to pay attention to what goes where in the configuration file. But first you need to know where the database configuration file is in your WordPress installation.

How to fix the error establishing a database WordPress issue

  1. Navigate to your WordPress root folder using FTP or a file manager (most commonly cPanel)
  2. Look for the file wp-config.php
WordPress root folder in cpanel or FTP

3. Download the file in FTP or edit it in your file editor (always make a backup of your file before you start editing!).

wp-config.php WordPress settings file in root folder

4. Look for DB_NAME and make sure your database name is entered correctly in between the apostrophes. If you’re not sure what your database name is, please look for it in MYSQL Databases in cPanel.

5. Look for DB_USER and make sure the username is entered correctly in between the apostrophes. If you’re not sure what this username is, you can find it under MYSQL Databases in cPanel. Make sure that your database has a username assigned to it and that this user has all the necessary privileges.

6. Make sure the DB_PASSWORD is entered correctly in between the apostrophes. If you’ve forgotten what the password is, you can reset it under MYSQL Databases.

7. In the VAST majority of WordPress installations, ‘localhost’ should be the correct setting for DB_HOST. But if you are sure you have entered your database credentials correctly and you are still having trouble, you might want to check with your host to make sure localhost is correct.

What if I’m still having the WordPress database error problem?

In a small number of cases, it’s possible the database may be corrupted. You can repair the database by navigating to PHPMyAdmin in Cpanel.

phpMyAdmin is located in Cpanel

Navigate to your database, select all of the tables, and click on repair tables.

How to repair database tables in phpMyAdmin

Are you still having database connection issues or do you need help locating your database username and password?

Check with your host to make sure your MYSQL database server is up and running!

I fix WordPress issues all day long and I can help you! Shoot me a quick message below or call 918-766-9699 to get fast help! If you’re the skeptical type, take a look at my raving reviews!

Fix My Website!
If you would prefer to speak over the phone, please leave a phone number.
This is optional but please fill it out for a quicker solution.
We NEVER share email addresses with anyone else.