Compressing data before sending

Tag: unix Author: nimadddd Date: 2009-10-11

I can copy the records from one server to another using the following command.

mysqldump -hlocalhost -uroot -pPassWord db tbl_name | 
        mysql -h100.100.100.100 -uroot -pPassword other_db tbl_name

But is it possible to zip it up while sending the data? for e.g.

mysqldump -hlocalhost -uroot -pPassWord db tbl_name | 
        gzip -cf | gunzip -c | 
        mysql -h100.100.100.100 -uroot -pPassword other_db tbl_name

and extract it on the other server to be executed using mysql command?

Best Answer

Yes here's blog post that shows you how

Other Answer1

You can compress the data while transferring it, but not within the mysqldump command. You have to transfer the compressed data in an explicit step, e.g.:

mysqldump -hlocalhost -uroot -pPassWord db tbl_name | gzip |
   ssh 100.100.100.100 "gunzip | mysql -hlocalhost -uroot -pPassWord db tbl_name"