Import & Export .bz2 MySQL Files

Import & export .bz2 MySQL database files with these simple commands — useful in automated shell scripts when you're exporting from a remote DB then importing into another like your local.
Typical Read
0 minutes
Share on facebook
Share on twitter
Share on linkedin
Sponsored Advertisement
Need a website or help with an existing one? Get a free quote today.

A comparison between a normal dump and a bzip2 results in a 78.35% decrease in file size.

Import .bz2 MySQL File

bunzip2 < db_filename.sql.bz2 | mysql -u root -p target_db_name

Export .bz2 MySQL File

mysqldump -u username -p databasename | bzip2 > db_filename.sql.bz2
Related Articles

Leave a Reply

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

All comments posted on 'Import & Export .bz2 MySQL Files' are held for moderation and only published when on topic and not rude. Get a gold star if you actually read & follow these rules.

You may write comments in Markdown. This is the best way to post any code, inline like `<div>this</div>` or multiline blocks within triple backtick fences (```) with double new lines before and after.

Want to tell me something privately, like pointing out a typo or stuff like that? Contact Me.