MYSQL_BASE=/opt/mysql
MYSQL_DATA=/data
MYSQL_USER=root
MYSQL_PASSWORD=password123
MYSQL_PORT=3306
MYSQL_LOGIN="${MYSQL_BASE}/bin/mysql -u${MYSQL_USER} -p${MYSQL_PASSWORD} -S ${MYSQL_DATA}/${MYSQL_PORT}/mysql.sock"
for i in ${MYSQL_LOGIN} -N -e "select user,host from mysql.user;"| awk ‘{print "‘‘‘" $1 "‘‘‘" "@" "‘‘‘" $2 "‘‘‘"}‘
; do ${MYSQL_LOGIN} -N -e " show grants for $i;"; done
#里面涉及了awk print单引号和双引号的小技巧
awk ‘{ print "‘t‘"}‘ #单引号
awk ‘{ print """}‘ #双引号