Create a mysql_backup directory in the /root directory to store mysql backup files
mkdir /root/mysql_backup
cd /root/mysql_backup
vi a script file
vi backup.sh
Add code to this file
backupdir=/root/mysql_backup time=`date +%Y%m%d%H`
mysqldump -uroor -proot databasename>$dackupdir/databasename$time.sql;
After programming, wq saves the file, where databasename is the name of the database you want to back up
Then give this file executable permission chmod 777 backup.sh
./backup.sql
Then directly execute the file to see if there is a .sql file generated;
----------------------------------------------------------------------
cd /etc
vi crontab
insert
29 16 * * * root /root/mysql_backup/backup.sh
Explain that at 16:29, root executes the backup.sh file under root/mysql_backup
Restart crontab service
/etc/rc.d/init.d/crond restart
mysql backup regularly