In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Linux in how to back up and restore mysql database, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
First, use commands to achieve backup
MySQLl provides a mysqldump command that we can use for data backup.
Enter the password as prompted, which backs up all the table structure and # mysqldump-u root-p tm > tm_050519.sql data of the tm database to tm_050519.sql, because the backup work is always carried out. If the amount of data takes up a lot of space, you can use gzip to compress the data, as follows:
# mysqldump-u root-p tm | gzip > tm_050519.sql.gz
When the system crashes and the system is rebuilt, the data can be recovered as follows:
# mysqldump-u root-p tm
< tm_050519.sql 从压缩文件直接恢复: #gzip < tm_050519.sql.gz | mysqldump -u root -p tm 当然,有很多MySQL工具提供更直观的备份恢复功能,比如用MyAdmin就很方便。但我认为,mysqldump是最基本、最通用的。 二、利用crontab,系统每天定时备份mysql 利用系统crontab来定时执行备份文件,按日期对备份结果进行保存,达到备份的目的。 1、创建保存备份文件的路径/var/backup/bak # mkdir -p /var/backup/mysqlbak 2、创建/usr/sbin/bakmysql文件 #vi /usr/sbin/bakmysql.sh #!/bin/bash# mysql备份脚本cd /var/backup/mysqlbak/dateDIR=`date +"%y-%m-%d"`mkdir -p $dateDIR/datafor i in `/usr/local/www/mysql/bin/mysql -uroot -plin31415926 -e "show databases" | grep -v "Database" | grep -v "information_schema"`do /usr/local/www/mysql/bin/mysqldump -uroot -plin31415926 $i | gzip >/ var/backup/mysqlbak/$dateDIR/$ {I} _ ${dateDIR} .gzdone
3. Modify the file properties to make it executable
# chmod + x / usr/sbin/bakmysql
4. Modify / etc/crontab
# crontab-e is it helpful for you to add 01 3 * root / usr/sbin/bakmysql below to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you 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.