Is there a MySql binary dump format? Or anything better than plain text INSERT statements?

Ollie Glass picture Ollie Glass · Sep 24, 2010 · Viewed 13.3k times · Source

Is there anything better (faster or smaller) than pages of plain text CREATE TABLE and INSERT statements for dumping MySql databases? It seems awfully inefficient for large amounts of data.

I realise that the underlying database files can be copied, but I assume they will only work in the same version of MySql that they come from.

Is there a tool I don't know about, or a reason for this lack?

Answer

codekoala picture codekoala · Sep 24, 2010

Not sure if this is what you're after, but I usually pipe the output of mysqldump directly to gzip or bzip2 (etc). It tends to be a considerably faster than dumping to stdout or something like that, and the output files are much smaller thanks to the compression.

mysqldump --all-databases (other options) | gzip > mysql_dump-2010-09-23.sql.gz

It's also possible to dump to XML with the --xml option if you're looking for "portability" at the expense of consuming (much) more disk space than the gzipped SQL...