Fix Error Establishing a Database Connection in Wordpress

0

 In some period of time while using WordPress you may get the error " Error Establishing a Database Connection".

Fix Error Establishing  Database Connection


This is a fatal error of WordPress that makes website access unable to the Users.

In this post, I will be explaining how to fix this issue of Error Establishing a Database Connection.

Reasons for Error Establishing a Database Connection:

This Error may occur due to the following reasons:

  • Your Login Information to the Database may be incorrect.
  • Your Database may be corrupted.
  • There may be corrupt files during WordPress installation.
  • There may be issues in your server like server traffic overload, server down, cannot giving access to concurrent users, etc.

5 Solutions for Fixing Error Establishing a Database Connection:

1. Validate that your database login information is correct (this is the most common issue).

Navigate to wp-config.php file and check your Database Name,Username, Password & Host Name or Server Name is correct.

// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'Database Name' );

/** Database username */
define( 'DB_USER', 'Username' );

/** Database password */
define( 'DB_PASSWORD', 'Password' );

/** Database hostname */
define( 'DB_HOST', 'Host Name' );

Note: wp-config.php is located on the root directory where WordPress is installed.

2. Repair your corrupt database with a built-in database repair function.

Navigate to the wp-config.php file and this line of code given below and save changes.

define(‘WP_ALLOW_REPAIR’, true);

3. Fix corrupt files of WordPress

To fix corrupt files of WordPress best option is to download the latest version of WordPress and reinstall it to your local system or to your hosting.

4. Contact or Check  your hosting provider for issues related to your database server

The reason may be from your hosting provider either the server is overloaded or server is down or it cannot handle multiple concurrent user requests or it may not support that version of WordPress you are using.

5. Restore to your latest backup

It is always a good practice of keeping a backup of your database frequently daily or weekly or monthly because whenever this kind of error occurs that you can restore your website using your backup files.

I hope the information that I have provided that is mentioned above has solved your problems and you are able to fix the WordPress problem Error establishing a database connection.

If you like my post then please share this post so that it makes me motivated for posting more useful information related to WordPress.

Thank You

Post a Comment

0Comments
Post a Comment (0)