I got the following error from a MySQL query.
#126 - Incorrect key file for table
I have not even declared a key for this table, but I do have i
mysql> set global sql_slave_skip_counter=1; start slave; show slave status\G
Then got error exists :
Error 'Table './openx/f_scraper_banner_details' is marked as crashed and should be repaired' on query. Default database: 'openx'. Query: 'INSERT INTO f_scraper_banner_details(job_details_id, ad_id, client_id, zone_id, affiliateid, comments, pct_to_report, publisher_currency, sanity_check_enabled, status, error_code, report_date) VALUES (10274859, 321264, 0, 31926, 0, '', -1, 'USD', 1, 'FAILURE', 'INACTIVE_BANNER', '2016-06-28 04:00:00')'
mysql> repair table f_scraper_banner_details;
This worked for me
I fixed this issue with:
ALTER TABLE table ENGINE MyISAM;
ALTER IGNORE TABLE table ADD UNIQUE INDEX dupidx (field);
ALTER TABLE table ENGINE InnoDB;
May helps
Every Time this has happened, it's been a full disk in my experience.
EDIT
It is also worth noting that this can be caused by a full ramdisk when doing things like altering a large table if you have a ramdisk configured. You can temporarily comment out the ramdisk line to allow such operations if you can't increase the size of it.
My issue came from a bad query. I referenced a table in FROM the was not referenced in SELECT.
example:
SELECT t.*,s.ticket_status as `ticket_status`
FROM tickets_new t, ticket_status s, users u
, users u
is what was causing the issue for me. Removing that solved the issue.
For reference this was in a CodeIgniter dev environment.
repair table myschema.mytable;