Why do I get a MySQL "error: 1016 Can't open file: ..."?
Errors such as: ..."Got error: 1016: Can't open file: 'YOUR_TABLE_NAME.MYI'. (error:145) when using LOCK TABLES"... (as well as numerous other noted below) are caused by MySQL table corruption. Table corruption can be caused by a variety of events, and will make some or all of a table unavailable.
Table corruption can also significantly decrease the performance of queries on effected tables. Table corruption can be be repaired by using the the REPAIR TABLE command.
For more information about the REPAIR TABLE command see:
MySQL 4.0, 4.1
Run REPAIR TABLE on an affected table
- Enter phpMyAdmin for the database you want to use. For more information, see Log in to phpMyAdmin.
- Click on the table name of the affected table.
Note: If phpMyAdmin is unable to display the table information, or encounters errors loading the table details page, another option would be to use the SQL button at the top of the left frame to enter your own query. You can repair the table manually by issuing the command REPAIR TABLE
in this SQL window.
- Click on the Operations tab at the top of the right panel.
- Click Repair table at the bottom of the right panel.
This command can take some time and will block some queries, such as inserts, to the table.
Some other errors that may be caused by table corruption include:
- Can't find file table.MYI.
- Duplicate unique key or constraint on write or update.
- Got error ERR from table handler. (ERR being a number).
- Index file is crashed / Wrong file format.
- No more room in index file.
- No more room in record file.
- Old database file.
- Record file is crashed.
- Record was already deleted (or record file crashed).
- table.frm is locked against change.
- Table is crashed and last repair failed.
- Tables was marked as crashed and should be repaired.
- Unexpected end of file.