Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysqldump compression

Tags:

I am trying to understand how mysqldump works:

if I execute mysqldump on my pc and connect to a remote server:

mysqldump -u mark -h 34.32.23.23 -pxxx  --quick | gzip > dump.sql.gz 

will the server compress it and send it over to me as gzip or will my computer receive all the data first and then compress it?

Because I have a very large remote db to export, and I would like to know the fastest way to do it over a network!

like image 303
Mark Belli Avatar asked Mar 27 '12 10:03

Mark Belli


People also ask

Does Mysqldump compress data?

yes, it reduces a lot data transfer! But what I wanted to understand was: if the mysqldump caches the data on my pc or on the remote server.. From what I understood it does transfer all the data on my pc first.

How do I compress a SQL file?

To use the WinRAR command-line utility, we set the PATH variable on the database server. Create a T-SQL script to generate a compressed and copy_only backup of the database. Using WinRAR command-line utility, compress and divide the backup file in multiple WinRAR files and copy them to the network location.

How can I speed up Mysqldump recovery?

Summary (for best dump restore performance):Set innodb_buffer_pool_size to half of RAM. Set innodb_log_file_size to 1G. Set innodb_flush_log_at_trx_commit to 0. Disabling innodb_double_write recommended only for fastest performance, it should be enabled on production.


1 Answers

You should make use of ssh + scp,
because the dump on localhost is faster,
and you only need to scp over the gzip (lesser network overhead)

likely you can do this

ssh [email protected] "mysqldump -u mark -h localhost -pxxx --quick | gzip > /tmp/dump.sql.gz"  scp [email protected]:/tmp/dump.sql.gz . 

(optional directory of /tmp, should be change to whatever directory you comfortable with)

like image 52
ajreal Avatar answered Sep 18 '22 15:09

ajreal