Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Extracting a single database a complete mysql dump file

I recently had to extract a database from a full backup, I only needed one database hardly 1MB in size but the whole backup exceeded 3GB and didn’t want to import all of it. Below is the command I found to make it work

 

First make a empty database with the same name you want to extract

CREATE DATABASE dbname;

Exit and run the following:

mysql -u root -p --one-database dbname < alldb.sql

Voila! you’re done.