HOWTO: Recover from old MySQL data files

Reminder for myself.

So you've got some backed-up MySQL table files (if that's the right term), rather than a proper dump. Untar them somewhere, and note the path to the data files -- say, /home/foo/mysql_recovery/data. Copy /etc/my.cnf to your home directory. Edit it and change the port to something different -- say, 3307. Run:

/usr/local/mysql/bin/mysqld --defaults-file=/home/foo/my.cnf --datadir=/home/foo/mysql_recover/data

Then run:

mysqldump -P 3307 --opt -u foo -p database > recovery.sql

Of course, all this could be prevented if you were running mysqldump nightly instead of just copying the data directories...