Question
I need to restore only part of my database. How can I extract and restore a specific table from a full backup dump?
Answer
You can use sed to dump the individual tables you need to an SQL file, then import that file to the databases. Replace mytable
with the table name you want to extract from the original MySQL Dump.
sed -n -e '/DROP TABLE.*`mytable`/,/UNLOCK TABLES/p' dump.sql > mytable.sql
To import, you can then use the MySQL command:
mysql -u root -p'password' mydatabase < mytable_restore.sql