In an urgent situation another person made a backup of all the databases from my webserver to one *.sql file (MySQL dump). Now I have a ~700 Mb file with about 20 different databases. As I only need one of them to restore at the moment, is there an easy way to select the only part I need (one database)? Of course I can try to simply select the needed text from the *.sql file to perform a query in PHPMyAdmin, but it is not so easy as the file is big.

2 Answers 2


Take the difference between two 'CREATE DATABASE' using sed operation


sed -n '/^-- Current Database: `dbname`/,/^-- Current Database: `/p' alldatabases.sql > output.sql



Restoring a single database from mysql enterprise full backup


Despite the fact that MySQLRockstar's answer is undoubtedly correct I haven't succeed with the sed script. I was my first time doing this, so I needed some more time to experiment and I was in a hurry.

I've had some experience with Perl so I succesfully used this approach https://stackoverflow.com/questions/1876754/split-up-a-mysqldump-file-with-multiple-databases-by-database/4347578#4347578 The script succesfully split my dump into separate files for each database. FYI I was doing this on Windows in command line after installing http://www.activestate.com/activeperl. Here is useful info for beginners: http://learn.perl.org/first_steps/

Hope this information is helpful!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.