Mysql – How to fix a MySQL “Incorrect key file” error when you can’t repair the table

MySQL

I'm trying to run a rather large query that is supposed to run nightly to populate a table. I'm getting an error saying Incorrect key file for table '/var/tmp/#sql_201e_0.MYI'; try to repair it but the storage engine I'm using (whatever the default is, I guess?) doesn't support repairing tables.

how do I fix this so I can run the query? We are under pressure to get this table loaded for a client.

Best Answer

That's not an actual table of yours, that's a temporary table created by the db to do some work. There's probably a left over tmp table file from a previous operation that's conflicting with whatever you're trying to do now. I'd suggest just stopping the server and running rm /var/tmp/*.MY{I,D}.