To backup all or some of your MySQL databases, you’ll need mysqldump which comes bundled with mysql. If you have MySQL installed, you probably have mysqldump installed already.
To backup all databases use the following command:
mysqldump -uroot -ppassword --all-databases | gzip > /media/disk-2/db.sql.gz
mysqldump -uroot -ppassword --all-databases > db.sql
This will backup all your databases from a single command.
To backup just a selected few use the following command:
mysqldump -uroot -ppassword --databases db1 db2 | gzip > db1db2.sql.gz
mysqldump -uroot -ppassword --databases db1 db2 > db1db2.sql
Replace db1 and db2 with your database names. You can add more databases separated by a space.
Replace ‘root’ and ‘password’ with your own mysql username and password.
Note that there is no space between ‘u’ and ‘root’ in -uroot, and between ‘p’ and ‘password’ in -ppassword
For more options please check out its man page if you are on linux or mysqldump --help which is available both in linux and windows.
It can’t get any simpler than that.