mysql-backup-restore-table

Dump a single table to a SQL file:

mysqldump -uuser -ppassword dbName tableName > backup.sql


If you want to get or restore a single table from a large MySQL dump file you can use the following methods:
Using AWK
Using Ruby
Using Perl:

#!/usr/bin/perl -wn BEGIN { $table = shift @ARGV; $printing = 0; } $printing = 1 if /^create table $tableb/io; exit if $printing && /^create table (?!$table)b/io; print if $printing;

Invocation:

perl gettablefromdump.pl tablename dumpfile.sql Related Posts: