Your Site Shows ‘Error Establishing a Database Connection’ or Corrupted Tables. Here Is How to Fix It.
A corrupted WordPress database can happen after a server crash, a failed update, or a plugin conflict. The result: your site goes down, your admin panel becomes inaccessible, and visitors see errors. WordPress includes a built-in repair tool that fixes most database corruption automatically.
“Database corruption sounds catastrophic, but WordPress has a built-in repair tool that fixes most issues automatically. It is the first thing to try before calling a developer.”
Running the Repair Tool
Enable database repair: Add define('WP_ALLOW_REPAIR', true); to wp-config.php. Run the repair: Visit yoursite.com/wp-admin/maint/repair.php. Click “Repair Database” or “Repair and Optimize Database.” WordPress checks every table for corruption and repairs any it finds. After repair: Remove the WP_ALLOW_REPAIR line from wp-config.php immediately — leaving it enabled is a security risk as anyone can access the repair page. Check your site — is it loading correctly? Are all pages working? Is the admin panel accessible? If repair fails: Restore from your latest backup. This is why daily backups matter — when the automatic repair cannot fix the issue, a clean backup is your recovery path. For professional database recovery, see our WordPress Services page.
“The database repair tool fixes most corruption in seconds. It is the first thing to try, the fastest path to recovery, and the reason you should not panic when your site goes down.”



