Troubleshooting · Troubleshooting
How to Fix Corrupted Database Tables in WordPress
Short answer
To fix corrupted WordPress database tables, back up the database first, then repair the damaged tables with WordPress's built-in repair page, phpMyAdmin, or the WP-CLI command wp db repair. Repair works on MyISAM tables, while damaged InnoDB tables usually need a rebuild or a restore from a clean backup. Remove the repair setting from wp-config.php as soon as you finish.
Key takeaways
- Back up the database before any repair, because a repair can discard rows it cannot read.
- The built-in repair page at wp-admin/maint/repair.php works without a login, so remove WP_ALLOW_REPAIR from wp-config.php right after use.
- REPAIR TABLE only works on MyISAM, ARCHIVE, and CSV tables, and InnoDB tables report that repair is not supported.
- A successful repair ends with a status of OK for each table in the check output.
- If repair fails or damage keeps returning, restore the database from your latest clean backup and ask your host to check the server.
What does “database tables need repair” mean?
It means WordPress found a table in its MySQL or MariaDB database that is damaged and cannot be read or written normally.
WordPress stores posts, pages, comments, users, and settings in database tables. When one of those tables is damaged, the affected part of the site stops working, and some pages may fail to load at all.
You may see the message “Error establishing a database connection” on the front of the site, while wp-admin says one or more database tables are unavailable. WordPress.org's Common WordPress Errors page says that connection message means there is a problem with the connection to the database.
What causes WordPress database tables to get corrupted?
Tables usually break when a write is cut off halfway, after a server crash, a power loss, a killed database process, or a disk that runs full.
Older MyISAM tables are the most exposed, because they keep data and indexes in plain files with no transaction log. InnoDB tables replay a redo log when the server restarts, so an ordinary crash rarely damages them, as the MariaDB guide to repairing tables explains.
Other causes include:
- A server crash or sudden power loss during a write.
- A disk that fills up while MySQL is writing.
- A database process that is killed or times out mid-write.
- Failing hardware or file system errors on the server.
MySQL's own manual makes the same point in plain terms: if your tables become corrupted often, find the reason for it instead of repairing the same tables again and again.
The MySQL 8.4 REPAIR TABLE reference says a repair is very likely to get back all your data from a MyISAM table, but repeated corruption means something else is wrong.
How do you know which table is damaged?
The error message, the debug log, or a table check usually names the exact table, so start there instead of guessing.
Turn on WP_DEBUG in wp-config.php and load the page again. WordPress only prints database errors when WP_DEBUG is set to true, as the Editing wp-config.php guide in the WordPress Developer Resources explains.
You can also check every table without changing anything. The WP-CLI command wp db check runs mysqlcheck with the --check flag against each table, using the credentials from wp-config.php, as the wp db check reference documents. phpMyAdmin has a “Check table” option that does the same job from the browser.
A healthy table returns OK. A damaged MyISAM table may be reported as crashed, which tells you a repair is genuinely needed rather than a guess.
What should you do before you repair anything?
Back up the database first, because a repair can discard rows it cannot read and can make damage worse.
The MySQL 8.4 manual warns to make a backup of a table before a repair, since the operation might cause data loss under some circumstances, including file system errors. That warning is on the MySQL 8.4 REPAIR TABLE reference page, checked November 2026.
- Export the database from your hosting panel, or run
wp db export before-repair.sqlover SSH. - Check the backup file exists and has a sensible size and today's date.
- Note the names of the damaged tables from the error message or the check output.
Keep the backup somewhere safe until the site works again. If the repair goes wrong, your next step is to restore the database from a backup, and that only works if the backup is good.
If you do not have a backup routine yet, set one up after the repair. Our guide to plugin backups vs hosting backups explains the two main ways to keep copies.
How do you repair tables with WordPress's built-in repair page?
Add one line to wp-config.php, open the repair page in your browser, and click “Repair Database”.
The wp-config.php file sits in the root of your WordPress files and holds the database connection details, so edit it through your host's file manager or SFTP. The Editing wp-config.php guide also warns to know how to restore a backup before you change settings in that file.
- Open wp-config.php in the site root with your host's file manager or SFTP.
- Add
define( 'WP_ALLOW_REPAIR', true );just above the line that says “That's all, stop editing! Happy publishing.” - Save the file and open yoursite.com/wp-admin/maint/repair.php in your browser.
- Click “Repair Database” and wait for the page to report on each table.
- Open wp-config.php again and delete the WP_ALLOW_REPAIR line.
Delete that line even if the repair failed. The repair page needs no login while the constant is set, so anyone who finds the address can start repair work on your database.
This tool only helps when the database is reachable and the damage is in a table. It cannot fix wrong login details in wp-config.php or a database server that is down.
WordPress.org lists wrong details in wp-config.php, a database that hit its quota, and a server that is down as the usual causes of a connection error, on its Common WordPress Errors page.
How do you repair tables in phpMyAdmin?
In phpMyAdmin, open the database, tick the tables, and choose “Repair table” from the “With selected” menu.
- Log in to your hosting panel and open phpMyAdmin from the Databases section.
- Click the name of your WordPress database in the left column.
- Tick the damaged tables, or click “Check All” to select them all.
- Choose “Check table” from the “With selected” menu to confirm which tables are damaged.
- Tick the damaged tables again and choose “Repair table” from the same menu.
Read the result for each table. A healthy table reports OK, and a repaired MyISAM table should report OK too. The hosting.com guide to repairing MySQL databases with phpMyAdmin walks through the same clicks in cPanel.
“Repair table” only works on MyISAM, ARCHIVE, and CSV tables. An InnoDB table will report that its storage engine does not support repair, which is normal and not a fault in phpMyAdmin. The MySQL 8.4 REPAIR TABLE reference says the statement repairs a possibly corrupted table for certain storage engines only.
How do you repair tables with WP-CLI?
From the site folder over SSH, run wp db check first, then wp db repair if the check finds damage.
The wp db check command runs mysqlcheck with the --check flag, using the database name, user, password, and host from wp-config.php. If it reports a damaged table, run wp db repair, which the WP-CLI reference says runs mysqlcheck with --repair=true.
wp db check
wp db repair
Run both commands from the WordPress installation folder, and export a backup first with wp db export before-repair.sql. Each table prints a line in the output, and a line ending in OK means that table passed.
| Method | Best when | What you need |
|---|---|---|
| WordPress repair page | wp-admin reports tables unavailable and you have no SSH | File manager or SFTP access to wp-config.php |
| phpMyAdmin | Shared hosting with no SSH | Hosting panel access |
| WP-CLI wp db repair | SSH access and repeatable checks | SSH and WP-CLI installed |
| Restore from backup | Repair fails or damage returns | A recent clean backup |
What if the damaged table uses InnoDB?
REPAIR TABLE does not fix InnoDB tables, so a damaged InnoDB table needs a rebuild or a restore from backup instead.
MySQL's manual says REPAIR TABLE repairs a possibly corrupted table for certain storage engines only, and InnoDB is not one of them. InnoDB is the default storage engine in MySQL and MariaDB, so most WordPress tables use it, as our guide to MySQL vs MariaDB for WordPress explains.
InnoDB recovers from an ordinary crash by itself when the server restarts, by replaying its redo log. Real InnoDB damage looks different: the server may refuse to start, or it may crash when one table is read.
The MariaDB guide to repairing tables says to restart MariaDB with innodb_force_recovery set to a low non-zero value, raising it until the server starts, then dump the data and rebuild the table.
Do not delete InnoDB files such as ibdata1 or the redo logs to fix corruption. That destroys data the server needs to recover, and the only way back is a backup.
If the server will not start at all, stop and ask your host for help. Forcing recovery settings on a live server is a job for someone who can read the database error log.
How do you check the repair worked?
Run the check again and load the site: every table should report OK and the error should be gone.
REPAIR TABLE returns a row for each table with Table, Op, Msg_type, and Msg_text columns, and the last row for a table should have a Msg_type of status and Msg_text of OK. That is how the MySQL 8.4 REPAIR TABLE reference describes a good result, as of November 2026.
If a MyISAM table still does not report OK, MySQL's manual says to try myisamchk --safe-recover from the server shell. If that also fails, restore the table from your backup instead of running more repair passes.
Then check the site itself. Load the home page and wp-admin, open a few posts and pages, and check that recent content is still there. A repair can drop rows it could not read, so compare against your backup if a post or comment is missing.
A 500 error after a repair points to a different fault, not the tables. See our guide to fixing the 500 internal server error if the site still fails to load.
When should you contact your host instead?
Contact your host when the database server is down, the disk is full, the repair keeps failing, or the damage is in an InnoDB table.
WordPress.org's troubleshooting page names two host-side causes for a database error: the database has met its quota and been shut down, or the server is down. Only your host can confirm and fix either one, as the Common WordPress Errors page explains.
Ask for help sooner rather than later if the same table crashes again after a repair, if the server exits during a repair, or if you have no backup to fall back on.
The MySQL manual notes that if the server exits during a REPAIR TABLE run, you must run the repair again after the restart, and a host engineer can do that safely.
Tell support the database name, the table name from the error, and what you already tried. Our guide to WordPress hosting requirements explains the database versions a good host should run, which helps you judge the answer you get.
What mistakes should you avoid?
Most database repairs go wrong in the same few ways, and all of them are easy to avoid.
- Repairing before taking a backup, so a bad repair leaves you with nothing to restore.
- Leaving WP_ALLOW_REPAIR in wp-config.php after the repair, which leaves the repair page open to anyone.
- Running REPAIR TABLE on an InnoDB table and assuming the “does not support repair” note means the table is fixed.
- Using REPAIR TABLE with USE_FRM as a first step, since it can lose the table's AUTO_INCREMENT value and other metadata.
- Repairing during peak traffic, when a repair can lock tables and keep the site down longer.
- Repairing the same crashed table again and again without finding why it keeps crashing.
Frequently asked questions
Can I repair WordPress database tables from wp-admin?
There is no repair button inside the WordPress dashboard. Instead, add WP_ALLOW_REPAIR to wp-config.php and open the repair page at wp-admin/maint/repair.php in your browser. The page works without a login, so delete the line from wp-config.php as soon as the repair is done.
Will repairing a table delete my posts?
It can. A repair rebuilds a damaged table and may discard rows it cannot read, so a post, comment, or setting stored in a damaged row can be lost. Always export a full database backup before you start, and check the site after the repair to see that recent content is still there.
Why does the repair say the storage engine does not support repair?
That message means the table uses InnoDB, which does not support the REPAIR TABLE statement. InnoDB recovers from ordinary crashes by itself when the server restarts. Real InnoDB damage needs a rebuild or a restore from backup, and often your host's help.
How long does a database repair take?
It depends on the size of the table and how much damage there is. Small tables on a shared host usually finish in seconds, while large tables with many rows can take minutes. The repair page and the command line both report on each table as they go, so you can watch the progress.
What if the repair page shows the same errors after running it?
Stop running more repair passes and restore the database from your latest clean backup. If the same table crashes again after a restore, ask your host to check the disk and the database server, since repeated corruption usually points to a hardware or server fault.
Do I need to repair tables after every server crash?
No. InnoDB tables recover on their own when the server restarts, and healthy MyISAM tables usually come back fine too. Only run a repair when an error message, the debug log, or a table check names a damaged table. Repeated crashes are a sign to find the cause, not to repair more often.
Sources
- Common WordPress Errors WordPress.org
- Editing wp-config.php WordPress Developer Resources
- REPAIR TABLE Statement MySQL 8.4 Reference Manual
- wp db repair WP-CLI Commands
- Repairing MariaDB Tables for SQL Server Users MariaDB Knowledge Base
- Optimizing and Repairing MySQL Databases Using phpMyAdmin Hosting.com Knowledge Base
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
