I'm trying to pull the database schema from a remote server, but mysqldump
is too slow to output (125+) tables' structures.
- If I enter the said server and run
mysqldump --compact --compress --no-data --add-drop-database --databases --user=myuser --password=123 mydb > dump.sql
it's almost instant. - If I run the same thing over ssh it takes 2.5 secs (
ssh myserver mysqldump [...] > dump.sql
) - However, if I use the
--host
so I can use the database credentials only, instead of the SSH credentials, it takes 2min40s to run!
What makes mysqldump so slow when running over its own protocol? It dumps each table (all at once) every few seconds, then waits, dumps the next one...
Is there anything I could do to make things faster?
EDIT: I wrote about that db adventure, to show the final solutions.
dump.sql
? How long does it take to transferdump.sql
with scp from the remote machine to your local machine? Is compression turned on for ssh? If not you could change the end of your command slightly to bemysqldump ... | gzip -c > dump.sql.gz
.