Import a compressed database dump


Problem

If you compress your dumps, you'll also have to uncompress them before you can import them, but maybe you can do all of this in one step?



Solution

Thanks to pipes you can always redirect the output of a programm to the input of another one. Most *nix console applications support this.

Assuming you've compressed your dump with bz2, you can use the command below to import it back into your database:

bunzip2 < dump.sql.bz2 | mysql <mysql options>

The same works for gunzip, simply replace bunzip2 and you're good to go.

Comments




Please sign-in to post a comment