Restoring single database from a MySQL dump file

A quick and practical way to extract a single database dump from a MySQL dump file:

sed -n '/^-- Current Database: `database1`/,/^-- Current Database: `/p' all_databases.sql > database1.sql

After that, simply go to MySQL prompt and load database1.sql using \. command.

Source:

https://www.configserverfirewall.com/mysqladmin/restore-one-database-all-database-dump/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s