It’s very important to keep your database server backed up, and Linux makes this a trivial task from the command line. You should really put this into a cron job and run it daily (or more often), but for our purposes today, this is how to actually do the backup.
The mysqldump utility creates a complete copy of the database in text format with INSERT statements and CREATE TABLE, etc. In fact, it wouldn’t take much work to restore the database onto a completely different database platform.
Anyway, here we go…
mysqldump -h localhost -u root -pmypassword databasename > dumpfile.sql
mysqldump -h localhost -u root -p2Uad7as9 database01 > dumpfile.sql
This will give you a text file containing all the commands required to recreate the database.