Skip to content

Recovering a crashed table on a cPanel MySQL host — MyISAM repair vs InnoDB rebuild

A "table marked as crashed" error means very different things on MyISAM and InnoDB. The wrong fix can extend the outage; the right fix takes minutes.

A cPanel customer wakes up to a 500 error. The PHP log shows Table './acmecorp_wp/wp_posts' is marked as crashed and should be repaired. The usual first instinct is mysqlcheck --repair. That works for MyISAM, sometimes. For InnoDB it does nothing — the message comes from a different code path and the recovery procedure is different. Picking the wrong tool extends the outage; picking the right one finishes recovery in minutes.

What’s happening

The “marked as crashed” error has two distinct origins:

  • MyISAM: the table file (.MYI or .MYD) has inconsistent state — usually because MySQL crashed mid-write or the disk filled. MyISAM has no transaction log, so it relies on REPAIR to walk the file and rebuild indexes. This sometimes works; sometimes the rebuild loses rows. Either way, the table is offline during repair.
  • InnoDB: less common. InnoDB has a redo log and survives crashes by replaying it on startup. If you see “marked as crashed” on InnoDB, it usually means the .ibd file is missing, has been touched by an external process, or has on-disk corruption — and REPAIR does not apply. The fix is innodb_force_recovery to start MySQL, dump the table, drop, recreate, reload.

Before deciding, identify the engine.

How to verify

mysql -e "SELECT ENGINE FROM information_schema.TABLES WHERE TABLE_SCHEMA='acmecorp_wp' AND TABLE_NAME='wp_posts'"
ls -la /var/lib/mysql/acmecorp_wp/wp_posts*
mysql -e "CHECK TABLE acmecorp_wp.wp_posts EXTENDED"
journalctl -u mariadb --since "1 hour ago" | grep -E "ERROR|crash|corrupt"
df -h /var/lib/mysql

The engine determines the recovery path. The ls confirms whether the table files exist and their sizes. CHECK TABLE EXTENDED runs the most thorough check. The journal often has the root cause (OOM, disk full, hardware issue). df is a sanity check — most “marked as crashed” we see was preceded by /var/lib/mysql hitting 100%.

The fix

For MyISAM:

  1. Try the safe repair first:
    mysql -e "REPAIR TABLE acmecorp_wp.wp_posts"
    If it returns “OK” the table is back. Verify with a SELECT.
  2. If safe repair fails, try extended:
    mysql -e "REPAIR TABLE acmecorp_wp.wp_posts EXTENDED"
    Slower; rebuilds index entries one row at a time.
  3. If extended fails, use offline repair: stop MySQL, run myisamchk --safe-recover /var/lib/mysql/acmecorp_wp/wp_posts.MYI, start MySQL. This bypasses the daemon entirely.
  4. As last resort, restore the table from backup. The MyISAM REPAIR can lose rows silently — mysqldump from yesterday is more trustworthy than a 99%-recovered table.
  5. Convert to InnoDB after recovery. A MyISAM table that crashed once is more likely to crash again. The conversion article covers this.

For InnoDB:

  1. Stop MySQL: systemctl stop mariadb.
  2. Enable innodb_force_recovery in /etc/my.cnf.d/cpanel.cnf:
    [mysqld]
    innodb_force_recovery = 1
    Start at level 1 (least invasive). Restart MySQL: systemctl start mariadb.
  3. Dump the affected table:
    mysqldump --single-transaction acmecorp_wp wp_posts > /tmp/wp_posts.sql
    If level 1 doesn’t let you dump, raise to 2, restart, retry. Don’t go higher than 4 — levels 5 and 6 can lose data.
  4. Drop and recreate the table from the dump:
    mysql -e "DROP TABLE acmecorp_wp.wp_posts"
    mysql acmecorp_wp < /tmp/wp_posts.sql
  5. Disable force_recovery and restart:
    /etc/my.cnf.d/cpanel.cnf:
    [mysqld]
    #innodb_force_recovery = 1  (comment out)
    systemctl restart mariadb. Now run normally.
  6. Root cause the crash. Disk full, kernel OOM kill, hardware fault — the table didn’t corrupt itself. Check dmesg, the MySQL error log, and the host’s monitoring history. If it was disk full, set up monitoring and the cleanup discipline so it doesn’t recur.

For environments where database corruption is becoming a pattern across multiple cPanel accounts, Stack Harbor’s environment management team adds monitoring on disk, OOM events, and per-account write rates, and root-causes the underlying instability before another recovery.