mysql导出用户权限

2019-09-09

mysql迁移用户前,需要查询

#!/bin/bash
#Function export user privileges

exp_grants()
{
mysql -B -u'root' -p'123456' -N $@ -e "SELECT CONCAT(
'SHOW GRANTS FOR ''', user, '''@''', host, ''';'
) AS query FROM mysql.user" | \
mysql -u'root' -p'123456' $@ | \
sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/-- \1 /;/--/{x;p;x;}'
}
exp_grants > ./results.sql

分类:Linux | 标签: |

相关日志

评论被关闭!