How to resolve “Error Establishing a Database Connection” in wordpress?

How to resolve “Error Establishing a Database Connection” in wordpress?

Team Leader Asked on February 11, 2017 in WORDPRESS.
Add Comment
1 Answer(s)

1. Incorrect Database Credentials in wp-config.php file.Add a new database user and update the Database Credentials in wp-config.php file.


/** The name of the database for WordPress */

define( 'DB_NAME', 'database_name_here' );
/** MySQL database username */

define( 'DB_USER', 'username_here' );
/** MySQL database password */

define( 'DB_PASSWORD', 'password_here' );
/** MySQL hostname */

define( 'DB_HOST', 'localhost' );

2. Database corruption:

You’ll need to download the wp-config.php file and add the following line:


define( 'WP_ALLOW_REPAIR', true );

After adding the above line you’ve re uploaded it to the server and you should be able to access a special database repair page on your server by going to http://yourdomain.com/wp-admin/maint/repair.php (yourdomain.com -> your domain). You should get a screen displaying two options: ‘Repair Database’ and ‘Repair + Optimize Database’.
Choosing either option should be fine, I would recommend choosing only to ‘Repair Database’.
Then go back into wp-admin.php and remove the above line of code from the wp-config.php file.

Team Leader Answered on February 25, 2017.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.