Aug 19, 2014
TnT Editor

How to Fix WordPress Error Establishing Database Connection

Sometimes WordPress site will display a default “error establishing database connection” error message page. Any number of problems can happen to cause this, such as cannot connect or having problem connecting to the database correctly, database login credentials wrong or have been changed, too many connections exceeding maximum connection allowed, or database server unresponsive or corrupted.

How to Fix Error Establishing Database Connection in WordPress

These WordPress error page are more meant for website administrators or webmasters rather than the public visitors. Further, the WordPress site may display “one or more database tables are unavailable. The database may need to be repaired”, then you need to repair your database. Here’s how to fix the error establishing a database connection in WordPress.

  1. WP-Config.php is probably the single most important file in entire WordPress installation. First, check all the wp-config.php file is correct and same without any changed.

             define(‘DB_NAME’, ‘your-database-name’);

             define(‘DB_USER’, ‘your-database-username’);

             define(‘DB_PASSWORD’, ‘your-database-password’);

             define(‘DB_HOST’, ‘your-localhost’);

  1. Next, check login page whether get errors for the same “Error Establishing Database Connection”. It may be getting a ton of traffic especially if you are using a shared server. Immediately contact hosting provider.
  2. If WordPress site shown “One or more database tables are unavailable. The database may need to be repaired” then you will need to repair your database.
    You can do this by adding the following line in your wp-config.php file:

             define(‘WP_ALLOW_REPAIR’, true)

  1. Once you have done that, you can see the settings by visiting this page: http://www.yoursite.com/wp-admin/maint/repair.php
  2. Next, the screen will appear with two repair options. Just click Repair Database.
    How to Fix WordPress Error Establishing Database Connection
  3. The WordPress site will recover once completed repair.
  4. Go to wp-config.php file and remove “define(‘WP_ALLOW_REPAIR’, true)”, and then Save the file.

Pin It on Pinterest

Share This

Share This

Share this post with your friends!