Skip to content
Mar 12 / jocke

Dump all MySQL-databases from command-line

Need to make a complete dump of all databases in your MySQL-server? Then this command is quite handy;

mysqldump -h <hostname> -u<user> -p --all-databases | gzip -9 > /location/for/backup/mysqldump.gz

This will prompt for a password — however, if you want to script it, you can of course put this in the command;

mysqldump -h <hostname> -u<user> -p<cleartext password> --all-databases | gzip -9 > /location/for/backup/mysqldump.gz

Also keep in mind that the database(s) will be locked while backing up, to avoid things to be written/changed/deleted while backing up (which would cause inconsistency).

Leave a Comment