For making a dump of a database directly in bz2 format, I tried zipping the dump file directly using pipes, as follows:
mysqldump -u userName -p myDataBase | bzip2 -c > myDump.sql.bz2
I want to do a similar thing for restore. I can do this using 2 commands as follows: command 1:
bzip2 -d myDump.sql.bz2
command 2:
mysql -u userName -p myDataBase < myDump.sql
Wanted:
Now I want to use the pipes to restore myDump.sql.bz2
to the database myDataBase
.
bzip2 -dc myDump.sql.bz2 | mysql -u userName -p myDatabase
- the -c option to bzip2 makes it send output to stdout, which you're already using when you created the dump.
try it:
bzcat dump.sql.bz2 | mysql -u name -p db
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With