MySQL: Incorrect key file error AND InnoDB: Error: unable to create temporary file; errno: 2

When I encounter the incorrect key file for table error, it’s almost certainly because the disk is full and MySQL can’t write to the tmpdir. The solution is simple, just move tmpdir to another partition with enough disk space.

Open my.ini and change tmpdir to another directory with enough disk space. Restart MySQL and that should do it.

However on Windows, such as for WAMP, you need to make sure you use slashes (/) rather than backslashes (\) in the path for tmpdir in my.ini, or it would be this error and mysqld would simply refuse to start:

InnoDB: Error: unable to create temporary file; errno: 2

Scroll to Top