1. Backup statement
[Plain] view plaincopy
- #/Usr/local/mysql/bin/mysqldump-utest-ptesttest -- socket =/tmp/mysql.3306.sock>/usr/local/mysql_backup/3306/test-'date1_policy1_m1_d'. SQL .gz
Statement description:
- /Usr/local/mysql/bin/mysqldump: Under the MySql installation directory
- -Utest: divided into two parts, one of which is-u and the other is test. The-u table shows that it is the user name, and the test table shows that it is the current user name.
- -Ptest: it can be divided into two parts, one of which is-u and the other is test. The-u table shows it as the password, and the test indicates the current password.
- -- Socket: Specifies the port to be backed up. Check which of the following matches the port/tmp.
- Test: Which database to back up
- >: The folder to which the backup is stored and named after the database name-current date.
2. Write the statement into a script.
3. edit/etc/crontab
[Plain] view plaincopy
- # Vim/etc/crontab
4. Add
[Plain] view plaincopy
- 003 *** root/home/mysql/3306/backup
Note: backup is the script you just wrote.
Indicates that a backup is performed at three o'clock every day.
5. Restart crontab
[Plain] view plaincopy
- #/Etc/rc. d/init. d/crondrestart