How To: Export all mysql databases for backup

This is a handy command for anyone using multiple mysql databases – it produces a single file which you can easily back up to elsewhere.


mysqldump -u root -p –all-databases > databasesBackup.sql


Note the two hyphens before “all”. This command creates the file databasesBackup.sql which contains the contents of all of your databases. This file can be easily rsync’d or scp’d elsewhere to create an offsite backup of your site’s databases.