MySQL ERROR 126 (HY000): Incorrect key file for table; try to repair it
MySQL can’t use a table’s index file — usually a full tmp disk during a query, or MyISAM corruption.
Seen on:
MySQL
Meaning
Large sorts/joins create temporary tables in tmpdir; if tmpdir fills up, MySQL reports “Incorrect key file” for the temp table. MyISAM tables can also corrupt after crashes.
Common causes
- tmpdir disk full during large queries
- MyISAM table corruption
- Crash during writes
⚡ Quick fix
- Free space in tmpdir (df -h /tmp) or move tmpdir
- REPAIR TABLE for MyISAM
- Convert MyISAM tables to InnoDB
Detailed fix by platform
MySQL
REPAIR TABLE wp_options; -- MyISAM only
How to diagnose
- Disk — tmpdir space?
- Engine — MyISAM or temp table?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026