Backing up your MySQL Database From the Command Line
Main
»
General
»
Backing up your MySQL Database From the Command Line
It is a a good idea to make regular backups of your MySQL database in case of a server crash or other unfortunate event. This article describes how backups can be made and restored from the command line. You may even want to create a cron job or windows scheduled task to automatically run these commands and create a backup on a regular basis.
To make a backup of your database using the 'mysqldump' command: mysqldump –-user [username goes here] –-password=[password goes here] [database name goes here] > [file name where the database will be saved] For example: mysqldump –-user databaseUser –-password=myPassWord myDataBase > myBackup.sql
If you ever need to restore the backup, you can run this command: mysql -u[username goes here] -p < [path to your backup file] For example: mysql -udatabaseUser -p myDataBase < myBackup.sql