126 incorrect key file 🐬 MySQL

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

  1. Free space in tmpdir (df -h /tmp) or move tmpdir
  2. REPAIR TABLE for MyISAM
  3. Convert MyISAM tables to InnoDB

Detailed fix by platform

MySQL

  1. REPAIR TABLE wp_options; -- MyISAM only

How to diagnose

  1. Disk — tmpdir space?
  2. 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.