How do I restore one database from a mysqldump containing multiple databases?

The Pixel Developer picture The Pixel Developer · Aug 29, 2010 · Viewed 24.1k times · Source

I have a mysql dump with 5 databases and would like to know if there is a way to import just one of those (using mysqldump or other).

Suggestions appreciated.

Answer

Tim picture Tim · Aug 29, 2010

You can use the mysql command line --one-database option.

mysql> mysql -u root -p --one-database YOURDBNAME < YOURFILE.SQL

Of course be careful when you do this.

You can also use a mysql dumpsplitter.