You can use the following command:
mysql -u root -p --one-database destdbname < alldatabases.sql
Where destdbname is your desired database that you want to restore.
Another option, which is IMHO much safer, is to extract the database from the dump --all-databases . 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. This way you will have a separate database in the file, and then you can restore it with a simple mysql command.
Good luck.
(Credits go to: Darren Mothersele - see his page )
Hetzbh Sep 22 '14 at 13:58 on 2014-09-22 13:58
source share