Sometimes, you may see a blank screen with an error message saying “error establishing a database connection” on your WordPress website. In this post, MiniTool Partition Wizard introduces some effective solutions to this error. Just read this post and work your problem out.

The “error establishing a database connection” issue is a common fatal error that prevents your WordPress website from being inaccessible to other users. Some reasons for this error are summarized as follows:

  • Incorrect database login credentials
  • Corrupted database
  • Corrupted installation files of WordPress
  • Database server problems
  • A sudden spike in traffic

Once you encounter the “error establishing a database connection WordPress” issue, you should take immediate measures to fix it. Or you may run into more issues like WordPress white screen. Here’re several possible methods available in the following content.

Method 1: Check Your Database Login Credentials

The “error establishing a database connection WordPress” issue is mainly caused by incorrect database login credentials. Therefore, once you meet this issue, you’d better check your database credentials. These credentials are stored in the wp-config.php file that is generally located at the root of your WordPress site.

Once you access the file, make sure the information including the database name, username, password, and database host is correct.

Method 2: Check Your Database Server

The WordPress error establishing a database connection issue may also occur when the database server (MySQL server) is down. Hence, after you experience the issue, you should check if there is something wrong with your MySQL server. To do this, you need to contact your hosting provider.

Method 3: Repair WordPress Database

As mentioned above, the corrupted WordPress database may lead to the WordPress error establishing a database connection. In this case, you ought to repair your database. To execute this operation, follow the steps below.

Step 1: Open the wp-config.php file and then add the following code to the bottom of the file:

define('WP_ALLOW_REPAIR', true);

Step 2: After that, go to on your browser.


Replace yoursitename with your website’s actual domain.

Step 3: Once you enter the database repair page, select either Repair Database or Repair and Optimize Database to repair your database.

Step 4: Once done, open the wp-config.php file again and remove the code you have added before.

Method 4: Fix the Corrupted Files

Another possible reason for the WordPress error establishing a database connection issue is corrupted WordPress files, such as a theme or a plugin. On this occasion, it’s recommended that you fix these files to see if the error is solved.

Step 1: Go to File Manager in hPanel or cPanel.

Step 2: Open the public_html folder and then open the wp_content folder.

Step 3: Right-click the plugins folder and select Rename.

Step 4: After renaming the corresponding folder, check if the error disappears. If so, the plugins are the culprit.

Step 5: To find out the specific problematic plugin, you can create a new plugins folder, move plugins one by one, and see if the WordPress website can run properly every time. Once you find the plugin causing the error, you should delete it or ask the plugin support team for help.


If the WordPress error establishing a database connection persists after renaming the plugins folder, you need to do the same with the themes folder.

If the error persists, then it may come from a corrupted plugin.

Method 5: Replace the Core WordPress Files

This way may also help you solve the “error establishing a database connection WordPress” issue. Here’s a full guide for you.


You should back up your WordPress site in advance in case any unexpected issues happen during the process.

Step 1: Go to and download a fresh copy of WordPress.

Step 2: After that, unzip the package. Then delete the wp-content folder as well as the wp-config-sample.php file inside the unzipped folder.

Step 3: Open an FTP client or File Manager. Then upload the remaining WordPress files to your website root folder. By doing so, all the corrupted files will be overwritten.

Step 4: After you replace the WordPress files, clear your browser cache and reload the website to see if the error is resolved.

All these methods mentioned above are available. When you are experiencing the “WordPress error establishing a database connection” issue, you can try them one by one until you solve this error. If you have any other great solutions to this issue, you can share them with us in the following comment area.

If you have difficulty managing your disks and partitions on your PC, you can try using MiniTool Partition Wizard. It’s a professional partition manager that offers a wide range of features. If you want to learn more about this program, you can visit the official website.

How to Fix Grey Screen on Windows 10? Here Is a Guide for You!
How to Fix Grey Screen on Windows 10? Here Is a Guide for You!

Similar to Blue Screen of Death, Grey Screen of Death is also a common issue for Windows 10. So, it is important to know how to fix Grey Screen on Windows 10.

Read More

  • Linkedin
  • Reddit