Extracting a table from a mysql.sql dump file [duplicate]
I found this nice solution, you have to download this script on your server and type
$> ./MyDumpSplitter.sh yourfile.sql your_table_name
This will extract your table into your_table_name.sql
Optionnal
Now you can rename it using this type of command
$> sed -i 's/`your_table_name`/`your_table_name2`/g' your_table_name.sql
And re-injecting it with
mysql> source your_table_name.sql;
I ran into that problem a while ago and wrote a Perl script. It worked well, but it was an older version of MySQL. Call it like:extract.pl -table=TABLENAME mysqldumpfile.sql > recovered_table.sql
#!/usr/bin/perl -s -wnl#extract a single table from a mysql dumpBEGIN { $table or warn "Usage: $0 -table=TABLE_TO_EXTRACT mysqldumpfile.sql" and exit 1;}/^DROP TABLE IF EXISTS `$table`/ .. /^UNLOCK TABLES;$/ and print;