Mac – Import sql.gz file with p7zip

I have been having problem with Mac extract program for gz files for a long time . and it caused me trouble to import compressed database dump from server . this is the mysql dump command i often use

mysqldump -u USER -p --single-transaction --quick --lock-tables=false DATABASE | gzip -9 > OUTPUT.gz

if you’re using Mac to extract zip and import database, you may see corrupted database or broken file in some cases. today, i’m sharing with you a good method to import compressed database with sql.gz at the end.

First, you will need homebrew on Mac, to find more information, please read this post : Mac OS X – Homebrew, the missing package manager

Then you can install p7zip with home brew.
brew install p7zip
Finally, use command like this to import to your database.
7z x -so <path_to_db_dump.sql.gz> | mysql -u<your_user_name> -p<your_password> <database_name>
Yay, it worked perfectly !! i hope you will like it 🙂

Leave a Comment