Import single database from --all-databases dump
You can use the following command:
mysql -u root -p --one-database destdbname < alldatabases.sql
Where destdbname
is your desired database which you want to restore.
Another option which is IMHO much safer, is to extract the DB from an --all-databases
dump. Example:
sed -n '/^-- Current Database: `dbname`/,/^-- Current Database: `/p' alldatabases.sql > output.sql
Replace dbname
with the desired database name. alldatabases.sql
is the name of your sql-dump file. That way you'll have the seperated DB on file, and then you can restore using a simple mysql command.
(Credits goes to: Darren Mothersele - see his page)
mysqldump
output is just a set of SQL
statements.
You can provide the desired database in the command line and skip the commands against the other databases using:
mysql -D mydatabase -o mydatabase < dump.sql
This will only execute the commands when mydatabase
is in use