#/bin/bash
##
##其实可以先判断目录存在么,可写么 [ -d .. ] [ -w .. ]
DATABASES=`mysql -usystem -p'oldboy123' -e "show databases"|grep -v "Database"`
for i in $DATABASES
do mysqldump -usystem -p'oldboy123' -B $i --skip-lock-tables|gzip >/scott/${i}_sql.backup.gz
done
转载于:https://blog.51cto.com/singler/1833580