1. Backup statement
Copy Code code as follows:
#/usr/local/mysql/bin/mysqldump-utest-ptest Test--socket=/tmp/mysql.3306.sock >/usr/local/mysql_backup/3306/ test-' Date +%y%m%d '. sql.gz
Statement Description:
/usr/local/mysql/bin/mysqldump:mysql installation directory
-utest: Divided into two pieces, one for-u piece for test, where-U is the user name, and test is the current user name
-ptest: Divided into two pieces, one for-u piece for test, where-U is the password, test is represented as the current password
--socket: Which port to back up, see/tmp below which one fits
Test: Which database to back up
: Which folder to back up, and named after the database name-the current date
2. Write the statement into a script
3. Edit/etc/crontab
Copy Code code as follows:
4, add the following
Copy Code code as follows:
3 * * * root/home/mysql/3306/backup
Note: Backup for the script you just wrote
Indicates that a backup is performed 3 o'clock daily
5. Reboot crontab
Copy Code code as follows:
#/etc/rc.d/init.d/crond Restart