Backup and Restore All MySQL Databases
Posted October 30th 2013 04:05 am
I routinely make mass backups of all of my MySQL databases, but sometimes forget the syntax when doing so. Instead of creating a script to do it (which I will do in the future), I have to Google the syntax to find out what it is. Most of the time, I can only find one or the other, so I thought I'd gather these two commands here and hopefully provide a better reference for anyone else searching.
Using a Linux Terminal:
Making a Full Backup (All Databases)
Using a Linux Terminal:
$ mysqldump -u [username] -p[password] --all-databases > [filename].sqlnotice that there is no space between
-p
and [password]
Restoring a Full Backup (All Databases)
Using a Linux Terminal:$ mysql -u [username] -p[password] < [filename].sqlnotice that there is no space between
-p
and [password]
Hope this helps others that scour the internet looking for these two common commands.