Backup & Restore MySQL database with compression option

If your MySQL database is very large, you may like to compress the output of mysqldump.
Use the MySQL backup command below & pipe the output to gzip, then you will get the output as gzip file.

$ mysqldump -u [user_name] -p [password] [database_name] | gzip -9 > [backupfile.sql.gz]

If you want to extract the .gz file, issue following command:
$ gunzip [backupfile.sql.gz]


To restore compressed backup files, issue following command:
$ gunzip < [backupfile.sql.gz] | mysql -u [user_name] -p [password] [database_name]

By above article you will easily backup & restore your MySQL database with compression option.

Note: Please don’t hesitate to revert in case of any query OR feedback.

Thanking you.
Have a easy life ahead.

Leave a Reply