In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to back up MYSQL database under CentOS". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to back up MYSQL database under CentOS".
First, write backup scripts
#! / bin/bash# backup path BACKUP=/opt/bak/data/# current time DATETIME=$ (date +% Y-%m-%d_%H%M%S) echo "= = backup start = =" # Database address HOST=localhost# database username DB_USER=root# database password DB_PW=*# database port DB_PORT=3306# create backup directory [!-d "${BACKUP} / $DATETIME"] & & mkdir-p "${BACKUP} / $DATETIME" # backup decentralized e-commerce production library DATABASE=*echo "backup file is stored in ${BACKUP} / ${DATETIME} _ $DATABASE.tar.gz" mysqldump-u$ {DB_USER}-p$ {DB_PW}-host=$HOST-P$ {DB_PORT}-Q-R-- databases $DATABASE | gzip > ${BACKUP} / $DATETIME/$DATABASE.sql.gz# compressed into tar.gz package cd $BACKUPtar-zcvf Delete backup file rm-rf ${BACKUP} / $DATETIME# after successful compression of ${DATETIME} _ $DATABASE.tar.gz $DATETIME# delete data backed up 60 days ago find $BACKUP-mtime + 60-name "* .tar.gz"-exec rm-rf {}\ Echo "= = backup succeeded ="
Change the permissions of the backup script
Chmod uplix / usr/local/tools/mysql_dy_backup.sh
Third, set the timing to execute script tasks
Crontab-e executed at 22:30 every day, you can add more than 30 22 * / usr/local/tools/mysql_dy_backup.sh thank you for reading, the above is the "how to back up MYSQL database under CentOS" content, after the study of this article, I believe you have a deeper understanding of how to back up MYSQL database under CentOS, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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: 298
*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.