Dump and restore zipped DB

Dump:
mysqldump -u<user> -p <dbname> -h <host> | bzip2 > dump.sql.bZ2

If your database on localhost, just skip -h <host>

If you want to include CREATE DATABASE statement use --databases <dbname> instead of <dbname>

Restore:
bzcat dump.sql.bZ2 | mysql -u<user> -p -D<dbname> -o

You can also set password in command line instead of entering it by prompt:

mysqldump -u<user> -p<password> ...

But remember that it will remain in your history (e.g. ~/.bash_history)

#mysql
0
Ivan Borshchov profile picture
Nov 21, 2016
by Ivan Borshchov
Did it help you?
Yes !
No

Best related