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 (
.MYIor.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_recoveryto 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:
- Try the safe repair first:
If it returns “OK” the table is back. Verify with a SELECT.mysql -e "REPAIR TABLE acmecorp_wp.wp_posts" - If safe repair fails, try extended:
Slower; rebuilds index entries one row at a time.mysql -e "REPAIR TABLE acmecorp_wp.wp_posts EXTENDED" - 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. - As last resort, restore the table from backup. The MyISAM REPAIR can lose rows silently —
mysqldumpfrom yesterday is more trustworthy than a 99%-recovered table. - Convert to InnoDB after recovery. A MyISAM table that crashed once is more likely to crash again. The conversion article covers this.
For InnoDB:
- Stop MySQL:
systemctl stop mariadb. - Enable
innodb_force_recoveryin/etc/my.cnf.d/cpanel.cnf:
Start at level 1 (least invasive). Restart MySQL:[mysqld] innodb_force_recovery = 1systemctl start mariadb. - Dump the affected table:
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.mysqldump --single-transaction acmecorp_wp wp_posts > /tmp/wp_posts.sql - Drop and recreate the table from the dump:
mysql -e "DROP TABLE acmecorp_wp.wp_posts" mysql acmecorp_wp < /tmp/wp_posts.sql - Disable force_recovery and restart:
/etc/my.cnf.d/cpanel.cnf: [mysqld] #innodb_force_recovery = 1 (comment out)systemctl restart mariadb. Now run normally. - 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.