Mysql Isolate One Table to Restore from Backup

In order to restore only one table from a mysql database backup file, you want to isolate the single table to another sql file.

Use SED on the shell command line:

sed -n -e '/-- Table structure for table `onetable`/,/-- Table structure/p' backup.sql > onetable.sql

You will want to DROP the table from the database. From the mysql command line:

DROP TABLE onetable;

Then again from the shell command line:

mysql -D database < onetable.sql

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.