Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best Way to to compress mysqldump?

Tags:

mysql

backup

I have a large mysqldump file on my server and I want to import it to my PC using FTP and it is taking forever as it is a large file.

I know there is a way to zip the contents of this file but I am not able to come-up with a precise command. What would be the best command to zip/compress a large mysqldump file?

Let's say the file name is backup.sql and it is in the folder named 'backup'.

Any help would be much much appreciated. Thank you in advance for your time.

like image 768
theoldtree Avatar asked Aug 11 '13 14:08

theoldtree


2 Answers

You can try something like this:-

mysqldump -u root -p database_name | gzip > dump.gz
like image 142
Rahul Tripathi Avatar answered Oct 13 '22 09:10

Rahul Tripathi


If your database is large, you should add this to your mysqldump

mysqldump -u root --single-transaction --quick --lock-tables=false database_name | gzip > database_name.sql.gz;
like image 21
Ashraf Avatar answered Oct 13 '22 10:10

Ashraf