In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
1. Creating shell scripts
vim backupdb.sh Create 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 Description: /usr/bin/mysqldump: mysqldump backup tool path in mysql database installation directory dbname: database name to backup/home/backup/$name.sql: Backup file output location, can be set according to the situation
2. Add execute permissions to shell scripts
chmod +x backupdb.sh
3. Add timed tasks to scripts
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 scheduled task above means that the automatic backup foot will be executed at 1 am every day to perform scheduled backup of MySQL database.
Description of crontab file:
Each line in the crontab file created by the user represents a timed task, and each field in each line represents a setting. Its format is divided into six fields in each line. The first five fields are the time setting fields, and the sixth field is the command field to be executed.
Minute hour day month week command
Parameter Description:
minute: It can be any integer from 0 to 59.
hour: Indicates the hour and can be any integer from 0 to 23.
Day: Indicates the date and can be any integer from 1 to 31.
Month: represents the month and can be any integer from 1 to 12.
week: indicates the day of the week, can be any integer from 0 to 7, where 0 or 7 represents Sunday.
command: The command to be executed can be a Linux system command or a script file written by yourself.
summary
The above is the MySQL database regular backup introduced by Xiaobian to you. I hope it will help you. If you have any questions, please leave a message to me. Xiaobian will reply to you in time. Thank you very much for your support!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.