How can I pipe output of bzip to mysql to restore data directly from bzipped file into a database
command-line, database-restore, linux, mysql, pipe
Solution
`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.
Problem
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`.