$ vim MyDatabaseUSers.sql
#!/bin/bash GRANT_CMDS=/tmp/ShowGrantsToExport.sql GRANT_FILE=MyDatabaseUSers.sql MYSQL_USER=root MYSQL_PASS=root MYSQL_CONN="-u${MYSQL_USER} -p${MYSQL_PASS}" SQL="SELECT CONCAT('SHOW GRANTS FOR ',QUOTE(user),'@',QUOTE(host),';')" SQL="${SQL} FROM mysql.user WHERE user<>'' AND host<>''" mysql ${MYSQL_CONN} -ANe"${SQL}" > ${GRANT_CMDS} mysql ${MYSQL_CONN} < ${GRANT_CMDS} | sed 's/$/;/g' > ${GRANT_FILE}
标签:GRANT,MYSQL,导出,CMDS,SQL,MySQL,权限,CONN From: https://www.cnblogs.com/abclife/p/16710826.html