In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to back up the database regularly in Linux. It is very detailed and has certain reference value. Friends who are interested must finish reading it.
Backup database regularly under Linux
The method of using crontab to back up MYSQL Database regularly under linux
Just follow these three steps and everything is under control:
Step 1: configure the backup directory code on the server:
Mkdir / var/lib/mysqlbackup cd / var/lib/mysqlbackup
Step 2: write the backup script code:
Vi dbbackup.sh pastes the following code, be sure to change the username,password and dbname in it. #! / bin/sh mysqldump-uuser-ppassword dbname | gzip > / var/lib/mysqlbackup/dbnamedate +% Y-%m-%d_%H%M%S.sql.gz cd / var/lib/mysqlbackup rm-rf find. -name'* .sql.gz'- mtime 10 # Delete backup files from 10 days ago
Step 3: change the permissions of the backup script
Chmod + x dbbackup.sh
Step 4: execute the backup script code regularly with crontab:
Crontab-e
If you back up at 21: 00 every night, add the following code
00 21 * / var/lib/mysqlbackup/dbbackup.sh
Problems you will encounter:
1.mysqldump is a backup database command, do not understand the direct Baidu is good.
2.Crontab is a command for scheduled tasks. If you don't understand it, you can visit http://www.thinkphp.cn/code/1....
3. Backup data must first make sure that a password has been set for root, otherwise it will be reported to mysqldump execution time Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect
Solution:
Log in to the mysql client
Mysql-hserverip-uroot-p mysql > use mysql; Database changed mysql > update user set password=password ('new password') where user='root'; Query OK, 4 rows affected (0.00 sec) Rows matched: 4 Changed: 4 Warnings: 0 mysql > flush privileges Query OK, 0 rows affected (0.00 sec) / / this command gives users new permissions or passwords to read directly into memory without the need to restart the database to prevent errors mysql > quit is all the contents of the article "how to back up the database regularly in Linux". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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: 284
*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.