In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to create a sub-database backup script for mysql database. The content of the article is carefully selected and edited by the author. It has a certain pertinence and is of great significance to everyone. The following is to learn with the author how to create a sub-database backup script for mysql database.
Mysql database sub-library backup script
Version 1
For dbname in `mysql-uroot-poldboy123-e "show databases;" | grep-Evi "database | informa | perfor" `
Do
Mysqldump-uroot-poldboy123-- events-B $dbname | gzip > / opt/bak/$ {dbname} _ bak.sql.gz
Done
Version 2
#! / bin/bash
MYUSER=root
MYPASS=oldboy123
MYCMD= "mysql-u$MYUSER-p$MYPASS-- default-character-set=utf8"
MYDUMP= "mysqldump-u$MYUSER-p$MYPASS-- default-character-set=utf8-- events-B"
DBLIST= `$ MYCMD-e "show databases;" | grep-Evi "database | informa | perfor" `
[!-d / opt/bak] & & mkdir-p / opt/bak
For dbname in $DBLIST
Do
$MYDUMP $dbname | gzip > / opt/bak/$ {dbname} _ bak.sql.gz
Done
Multi-instance sub-database backup
#! / bin/bash
MYUSER=root
MYPASS=oldboy123
SOCKET=/data/3306/mysql.sock
MYCMD= "mysql-u$MYUSER-p$MYPASS-default-character-set=utf8-S $SOCKET"
MYDUMP= "mysqldump-u$MYUSER-p$MYPASS-- default-character-set=utf8-S $SOCKET-- events-B"
DBLIST= `$ MYCMD-e "show databases;" | grep-Evi "database | informa | perfor" `
[!-d / opt/bak] & & mkdir-p / opt/bak
For dbname in $DBLIST
Do
$MYDUMP $dbname | gzip > / opt/bak/$ {dbname} _ bak.sql.gz
Done
After reading the above about mysql database how to create sub-database backup script, many readers must have some understanding, if you need to get more industry knowledge and information, you can continue to follow our industry information column.
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.