MySQL used all drive space running an ALTER and now won’t start

disk-spaceinnodbMySQL

I tried to alter a table without paying attention to the size, and MySQL ate up all the free space on the drive. I deleted a million or so old records but the space was still being used.

Googling suggested that restarting the MySQL server would help, but the server won't start:
[FAIL] /etc/init.d/mysql: ERROR: The partition with /var/lib/mysql is too full! ... failed!

So now I'm a bit stuck. My database only has one (very big) table:

# ls -lh
total 18G
-rw-r--r-- 1 mysql mysql    0 Sep 25  2014 debian-5.5.flag
-rw-rw---- 1 mysql mysql  18G Jul 13 15:17 ibdata1
-rw-rw---- 1 mysql mysql 5.0M Jul 13 15:17 ib_logfile0
-rw-rw---- 1 mysql mysql 5.0M Jul 13 15:15 ib_logfile1
drwx------ 2 mysql mysql 4.0K Jul 13 11:44 log
drwx------ 2 mysql mysql 4.0K Sep 25  2014 mysql
-rw------- 1 mysql mysql    6 Sep 25  2014 mysql_upgrade_info
drwx------ 2 mysql mysql 4.0K Sep 25  2014 performance_schema
drwx------ 2 mysql mysql 4.0K Dec  4  2013 test

So, specifically, my question is: how do I free up the drive space that MySQL used when I tried to alter a large table?

[edit]I should mention that I've got no space on any other drives, and I can't change the size of the drive either 🙁

[edit2]In response to comments:

mysql> OPTIMIZE TABLE `emails`;
+------------+----------+----------+-------------------------------------------------------------------+
| Table      | Op       | Msg_type | Msg_text                                                          |
+------------+----------+----------+-------------------------------------------------------------------+
| log.emails | optimize | note     | Table does not support optimize, doing recreate + analyze instead |
| log.emails | optimize | error    | The table '#sql-8aa_25' is full                                   |
| log.emails | optimize | status   | Operation failed                                                  |
+------------+----------+----------+-------------------------------------------------------------------+
3 rows in set, 1 warning (1 hour 12 min 10.62 sec)

# df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs           20G   19G     0 100% /
udev             10M     0   10M   0% /dev
tmpfs           100M  128K  100M   1% /run
/dev/xvda1       20G   19G     0 100% /
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           200M     0  200M   0% /run/shm

Best Answer

Find the file #sql-8aa_25 and remove it. It is probably in the same directory where the database is.

If you did a kill -9, mysqld did not get a chance to remove the tmp file.