< Back to Posts

Extracting a database from a large mysqldump file

Richard

#linux


Restoring a single database from a large mysql dump is pretty easy, using the mysql command line client's --one-database option:

mysql -u root -p --one-database db_to_restore < fulldump.sql
                

But what if you don’t want to restore the database, you just want to extract it out of the dump file? Well, that happens to be easy as well, thanks to the magic of sed:

sed -n '/^-- Current Database: `test`/,/^-- Current Database: `/p' fulldump.sql > test.sql
                

Let's make something great together!

If you'd like to discuss your next project with us, please feel free to give us a call on 01827 781 311 or press the "Start My Project" button to get in touch for a quick quote.

Start My Project