Backup and Restore All MySQL Databases

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.

Making a Full Backup (All Databases)


Using a Linux Terminal:
$ mysqldump -u [username] -p[password] --all-databases > [filename].sql
notice 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].sql
notice that there is no space between -p and [password] Hope this helps others that scour the internet looking for these two common commands.


Tags:#mysql #linux #backup #restore