Extract Backup of one database from mysqldump all databases

When you backup MySQL Server with command

mysqldump  --all-databases > all-db.sql

You get a MySQL backup file containing all databases.

If you want to generate MySQL backup for single database from this file, you can run

Advertisement

sed -n '/^-- Current Database: `DB_NAME`/,/^-- Current Database: `/p' all-db.sql > DB_NAME.sql
Add a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Advertisement