February 28, 2012

Dump a single table to a file in mysql.

For some reason I always find myself searching for a way to dump a single temp table out of mysql.

Backup a single table from the database:
mysqldump -u -p database_one table_name > /var/www/backups/table_name.sql

Restore the table into another database:
mysql -u -p database_two < /var/www/backups/table_name.sql