Bitecode blog

Knowledge for JVM-hungry people

Dumping large MySQL database

During some troubleshooting on one of projects I needed to get latest dump from remote mysql database server I couldn’t ssh to. Easy thing… but the database was actually quite huge…

Problem

Not going into details of credentials basic mysqldump command looks like this:

mysqldump database > database_dump.sql

Dump file size was ~3GB which might take quite long. Especially when the connection to mysql server was not fast enough.

Solution

After a few attempts and noticing that it might take too long to fetch all data I found out that there is a nice switch in mysql and mysqldump commands.

--compress, -C

Switch will tell mysql server to compress the dump on the fly so you can save a lot of bandwidth. However both sides needs to support the setting. Note that you may also use that switch with mysql command.