Mysql – Restoring a single database from thesql enterprise full backup

MySQLmysql-5.5mysqldump

I am having command to restore all databases from full dump taken by enterprise full backup .Can anyone help me how to restore single database from full dump .

Best Answer

Try this:

mysql -u root -p --one-database destdbname < alldatabases.sql

In the above code substitute destdbname with the database name you want to restore, and alldatabases.sql with the name of your full DB backup.

If you would rather just extract the database dump of the single database from the --all-databases dump file, you can do this with sed using this command:

sed -n '/^-- Current Database: `dbname`/,/^-- Current Database: `/p' alldatabases.sql > output.sql

Where dbname is replaced with the database name of the database to extract, and alldatabases.sql is the name of your dump file. The result will be saved into the file output.sql.