Sometimes, you may experience “ERROR 1034: Incorrect key file” while running the ALTER TABLE or CREATE INDEX command:
mysql> alter table ontime add key(FlightDate); ERROR 1034 (HY000): Incorrect key file for table 'ontime'; try to repair it
As the error message mentions key file, it is reasonable to assume we’re dealing with the MyISAM storage engine (the legacy storage engine which used to have such a thing), but no, we can clearly see this table is InnoDB!
When the error message in MySQL is confusing or otherwise unhelpful, it is a good idea to check the MySQL error log:
2019-02-24T02:02:26.100600Z 9 [Warning] [MY-012637] [InnoDB] 1048576 bytes should have been written. Only 696320 bytes written. Retrying for the remaining bytes. 2019-02-24T02:02:26.100884Z 9 [Warning] [MY-012638] [InnoDB] Retry attempts for writing partial data failed. 2019-02-24T02:02:26.100894Z 9 [ERROR] [MY-012639] [InnoDB] Write to file …[Read more]