MySQL – Restore a Single Table from a FULL mysqldump file

0
605

Use the sed command on your bash shell to separate the data of the table that you want to restore. For example, if we want to restore only the “moodle_files” table to “ac_files” database we execute the script below.


sed -n -e '/DROP TABLE.*`mytable`/,/UNLOCK TABLES/p' mydump.sql > tabledump.sql

You can now import the newly created table dump file into MySQL database.

mysql -u root -p ac_files < moodle_files.sql

LEAVE A REPLY

Please enter your comment!
Please enter your name here