1. Create a shell script vim backupdb.sh Create the script as follows: #!/bin/sh db_user="root" db_passwd="123456" db_name="userdb" name="$(date +"%Y%m%d%H%M%S")" /usr/bin/mysqldump -u$db_user -p$db_passwd $db_name >>/home/backup/$name.sql illustrate: /usr/bin/mysqldump: the path of the mysqldump backup tool in the mysql database installation directory dbname: the name of the database to be backed up /home/backup/$name.sql: the backup file output location, which can be set according to the situation 2. Add execution permissions to the shell script chmod +x backupdb.sh 3. Add a scheduled task to the script crontab -e Enter the name of the previous line to edit the scheduled task, and finally add the following content 00 01 * * * /bin/sh /usr/local/mysql/backupdb.sh The above scheduled task means that the automatic backup script will be executed at 1:00 a.m. every day to perform a scheduled backup of the MySQL database. Description of crontab file: In the crontab file created by the user, each line represents a scheduled task, and each field in each line represents a setting. Its format is divided into six fields per line. The first five fields are time setting fields, and the sixth field is the command field to be executed. The format is as follows: minute hour day month week command Parameter Description: minute: represents the minute, which can be any integer from 0 to 59. Summarize The above is the scheduled backup of MySQL database introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: How to implement remote access control in Centos 7.4
>>: Three solutions for sub-functions accessing external variables in JavaScript
I have always been interested in wireless interac...
The difference between inline elements and block-...
Preface The requirement implemented in this artic...
Understanding of diff algorithm in React diff alg...
1. Add an empty element of the same type, and the...
If the server's images are hotlinked by other...
"Development is more than just writing code&q...
Table of contents The concept of affairs The stat...
We know that MySQL is a persistent storage, store...
var numA = 0.1; var numB = 0.2; alert( numA + num...
1. Installation Package MYSQL service download ad...
Preface When you install MySQL, you usually creat...
Aggregate functions Acts on a set of data and ret...
To achieve CSS screen size adaptation, we must fi...
How is Line-height inherited?Write a specific val...