If your WordPress site is slow, showing errors, or behaving unexpectedly, repairing the database can often resolve the issue.
How to Repair the Database
- Open your
wp-config.phpfile - Add the following line:
define('WP_ALLOW_REPAIR', true);- Save the file
- Visit this URL in your browser:
https://yourdomain.com/wp-admin/maint/repair.php- Choose one of the options:
- Repair Database
- Repair and Optimize Database
Important
- No login is required to access this page
- Remove the line from
wp-config.phpafter use:
// Remove this after repair
define('WP_ALLOW_REPAIR', true);When to Use This
- Database connection errors
- Slow backend performance
- Corrupted tables
Tip: Always take a database backup before running repairs.