MYUSER=root
MYPASS=123456
SOCKET=/data/3306/mysql.sock
MYCMD="mysql -u$MYUSER -p$MYPASS -S $SOCKET"
BAKPATH="/backup/$(date +%F)"
[ ! -d $BAKPATH ] && mkdir -p $BAKPATH
for dbname in `$MYCMD -e 'show databases;'|sed '1d'|grep -v "_schema"`
do
$MYDUMP -B -x --events $dbname|gzip >$BAKPATH/${dbname}.sql.gz
if [ $? -eq 0 ];then
echo "$dbname" >>$BAKPATH/${dbname}.log
fi
done
CentOS 6.8 x86_64bit shell实现mysql多实例分库备份
原文:http://blog.51cto.com/11047966/2070115