Chat with us, powered by LiveChat

Troubleshooting "error establishing database connection" on a WordPress site

Category: Web Hosting

There are a few reasons that you might receive an “error establishing database connection” message from your WordPress installation. Here are some of the causes, and how to fix them.

The database connection details in your wp-config.php file are incorrect

The first thing you should do is verify that the database connection information in your website’s wp-config.php file is correct. You can open the wp-config.php file by following these steps:

  1. Log in to cPanel
  2. Click on the File Manager option
  3. Navigate to the public_html folder (or the folder in which your website is stored).
  4. Right-click on the wp-config.php file, then click Edit.

Once you have the file open, you can view the database’s name and the associated user under cPanel > MySQL Databases.

You can use this information to verify that the details inside the wp-config.php file are correct, except for the server address, which should be set to localhost.

The MySQL extensions for PHP are not enabled

Sometimes the extension that allows PHP to connect to your MySQL database is not enabled. You can check if this is the case under cPanel > Select PHP Version.

Depending on the PHP version set, you will see any of the following extensions in the list.

  • mysqlnd
  • nd_mysqli
  • nd_pdo_mysql

Normally, enabling mysql or mysqli will resolve the problem. In some rare cases, you may need to enable mysqlnd and nd_mysql.

The MySQL Database for WordPress is corrupt and needs to be repaired

Sometimes there are issues with the data inside your website’s database, which can be fixed using WordPress’s inbuilt database repair tool. To use the tool, follow these steps:

  1. Login to cPanel
  2. Click on the File Manager option
  3. Navigate to the public_html folder (or the folder in which your website is stored).
  4. Right-click on the wp-config.php file
  5. Click Edit
  6. Add this line of code to the file define('WP_ALLOW_REPAIR', true);
  7. Click Save Changes
  8. Navigate to http://www.mydomainname.com/wp-admin/maint/repair.php in your web browser
  9. Follow the prompts to repair the database

The MySQL Server is down or inaccessible for some reason

If you have tried all of the above and your website is still displaying the connection error, the MySQL Database Server may be down. In which case, you will need to contact our technical support team for assistance.

More Info Request
  • Select All
  • Sample Pricing Guide
    Due to the nature of our services as a wholesale provider, we do restrict full pricing from being released. You can request a sample pricing guide to give you some insight as to what you can look forward to by becoming a partner with Synergy Wholesale.
  • API Information
  • Whitelabel Billing Information
  • Migration Process
Required
* Required
Thank you for submitting a More Info Request!
An email will be sent to you shortly with the requested information.
Begin your 7-day free-trial today!
Get Started
Close