Administration-Related Issues To alleviate the problem, take the following actions: Exceptions to the preceding behavior are when you use  REPAIR TABLE  or  OPTIMIZE TABLE  or when the indexes are created in a batch after  LOAD DATA  or after an  ALTER TABLE  statement. All of these statements may create large temporary files that, if left to themselves, would cause big problems for the rest of the system. If the disk becomes full while MySQL is doing any of these operations, it removes the big temporary files and mark the table as crashed. The exception is that for  ALTER TABLE , the old table is left unchanged. On Unix, MySQL uses the value of the  TMPDIR  environment variable as the path name of the directory in which to store temporary files. If  TMPDIR  is not set, MySQL uses the system default, which is usually  / tmp ,  /var/tmp , or  /usr/tmp . On Windows, MySQL checks in order the values of the  TMPDIR ,  TEMP , and  TMP  environment variables. For the first one found to be set, MySQL uses it and does not check those remaining. If none of  TMPDIR , TEMP , or  TMP  are set, MySQL uses the Windows system default, which is usually  C:\windows	emp\ . If the file system containing your temporary file directory is too small, you can use the  mysqld --tmpdir option to specify a directory in a file system where you have enough space. The  --tmpdir  option can be set to a list of several paths that are used in round-robin fashion. Paths should be separated by colon characters ( : ) on Unix and semicolon characters ( ; ) on Windows. To spread the load effectively, these paths should be located on different  physical disks, not different partitions of the same disk. If the MySQL server is acting as a replica, you can set the  slave_load_tmpdir  system variable to specify a separate directory for holding temporary files when replicating  LOAD DATA  statements. This directory should be in a disk-based file system (not a memory-based file system) so that the temporary files used to replicate LOAD DATA can survive machine restarts. The directory also should not be one that is cleared by the operating system during the system startup process. However, replication can now continue after a restart if the temporary files have been removed. MySQL arranges that temporary files are removed if  mysqld  is terminated. On platforms that support it (such as Unix), this is done by unlinking the file after opening it. The disadvantage of this is that the name does not appear in directory listings and you do not see a big temporary file that fills up the file system in which the temporary file directory is located. (In such cases,  lsof +L1  may be helpful in identifying large files associated with  mysqld .) When sorting ( ORDER BY  or  GROUP BY ), MySQL normally uses one or two temporary files. The maximum disk space required is determined by the following expression: (length of what is sorted + sizeof(row pointer)) * number of matched rows 5304 Note B.3.3.5 Where MySQL Stores Temporary Files •Other threads might be waiting for the table that caused the disk-full condition. If you have several “locked”  threads, killing the one thread that is waiting on the disk-full condition enables the other threads to continue. •Alternatively, to abort the thread, use  mysqladmin kill . The thread is aborted the next time it checks the disk (in one minute). •To continue, you only have to free enough disk space to insert all records.