分分彩平台搭建分库
企 娥:217 1793 408
[[email protected] scripts]# cat backup_database.sh
#!/bin/bash
mysql_user=root
mysql_pass=123456
mkdir -p /backup
for n in mysql -u$mysql_user -p$mysql_pass -e ‘show databases;‘ 2>/dev/null|grep -Ev ‘_schema|mysql‘|sed ‘1d‘
;
do
mysqldump -u$mysql_user -p$mysqlpass -B $n 2>/dev/null>/backup/${n}date +%Y_%m_%d
.sql
done
分库分表
[[email protected] scripts]# cat backup_tables.sh
#!/bin/bash
mysql_user=root
mysql_pass=123456
mkdir -p /backup
for n in mysql -u$mysql_user -p$mysql_pass -e ‘show databases;‘ 2>/dev/null|grep -Ev ‘_schema|mysql‘|sed ‘1d‘
;
do
mkdir -p /backup/$n
for m in mysql -u$mysql_user -p$mysql_pass $n -e "show tables;" 2>/dev/null|sed ‘1d‘
;
do
mysqldump -u$mysql_user -p$mysqlpass $n $m 2>/dev/null>/backup/${n}/${m}date +%Y_%m_%d
.sql
done
done
原文地址:http://blog.51cto.com/13852526/2136081