in Web and Tech, Work

WP: Error connecting to database

When you’re getting an error that says “Error connecting to your database” once you login to your WP-admin, chances are that you’ve got a corrupted database.

To fix this, you’ll need to enable WP_ALLOW_REPAIR via wp-config.php. Got to the last line on the file, and enter the line like so:

define('WP_ALLOW_REPAIR', true);

Load the updated config.php back to the site and then enter the following URL on your browser:

https://yoursite.name/wp-admin/maint/repair.php

And just follow the onscreen instructions. You have the option to “Repair Database” and “Repair and optimize”. Either will do the fix but just bear in mind that repair and optimize will take a little longer.

After the fix, make sure to delete or comment out the line that was added on the config.php file.

A video about this can be found here:

Write a Comment

Comment