How to resolve “Error Establishing a Database Connection” in wordpress?
How to resolve “Error Establishing a Database Connection” in wordpress?
Share
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Aviance School is one of the largest web solutions platform in India for developers to learn and share their programming knowledge and build their careers.
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.