A table marked as crashed: what it means and how to repair it

The message Table is marked as crashed and should be repaired means a table, almost always of the MyISAM type, has an inconsistent file, usually because something stopped halfway through a write. In most cases it is fixed with Repair table in phpMyAdmin or in cPanel. First, make a copy of whatever you can still read.

Step by step

1 Copy first. If you can export, export. See exporting with phpMyAdmin. If you cannot, at least save the table name and the full message.
2 In cPanel open MySQL Databases. Under Modify Databases, choose the database and click Repair DB.
3 Or in phpMyAdmin: open the database, tick the table, and in the “With selected” menu choose Repair table. It is the same as running REPAIR TABLE table_name; on the SQL tab.
4 Run CHECK TABLE table_name; and confirm the status is OK.
5 Open the site and confirm the message is gone.
6 To keep it from coming back, convert the table to InnoDB: ALTER TABLE table_name ENGINE=InnoDB;. Do it with the copy already made.
Situation What to do
MyISAM with the “crashed” message REPAIR TABLE. Usually enough.
InnoDB with errors REPAIR TABLE does not apply. Restore from a copy. See restoring your data with JetBackup.
The repair fails or loses rows Restore the table, or the database, from the most recent copy you have.
In WordPress, several table errors Use WordPress’s own repair (below).
WordPress’s repair leaves a door open. Add define('WP_ALLOW_REPAIR', true); to wp-config.php, open /wp-admin/maint/repair.php on the site, repair, and remove the line right afterwards: while it is there, anyone can open that page without logging in. And if you see the message once, after a failure, it may have been a one-off; if it comes back, switch to InnoDB and check for a full disk.

Why it happens

A table gets marked as damaged when something interrupts a write halfway: a restart of the server, a process killed for lack of resources, or an account with no space left to write. MyISAM tables are the most sensitive to this, because they lack the log InnoDB uses to repair itself. That is why the underlying advice is to use InnoDB. A table marked as damaged does not mean someone broke into the site: nearly always it is just a write that was left half done. Even so, change the passwords if you have any doubt, and look at the access log for requests you do not recognise.

Real backups remove the scare. Someone with a daily copy recovers in minutes. See making and keeping your own backup and database connection errors.

The repair did not work or the database is incomplete? Tell us the database name and the message and we will see what can be recovered.

Open a support ticket

SEE ALSO

How to restore your data with JetBackup

Error establishing a database connection: the causes, in order

Cleaning and optimising the database in phpMyAdmin

RECOMMENDED PRODUCT

Web hosting with cPanel

Domain and SSL included, daily backups and the panel you already know. from $6.60/mo (3-year plan, with coupon)

See plans
  • 0 Users Found This Useful
Was this answer helpful?