下文主要给大家带来mysql用户权限如何批量获取,希望这些文字能够带给大家实际用处,这也是我编辑mysql用户权限如何批量获取这篇文章的主要目的。好了,废话不多说,大家直接看下文吧。
-- 云服务器级别的权限
select a.GRANTEE,GROUP_CONCAT(a.PRIVILEGE_TYPE), concat("grant ",GROUP_CONCAT(a.PRIVILEGE_TYPE)," ON *.* to " ,a.GRANTEE ) from USER_PRIVILEGES a GROUP BY GRANTEE ;
-- db 级别的权限
select GRANTEE,TABLE_SCHEMA,GROUP_CONCAT(PRIVILEGE_TYPE), concat("grant ",GROUP_CONCAT(PRIVILEGE_TYPE)," ON ",TABLE_SCHEMA,".* to " ,GRANTEE ) from information_schema.SCHEMA_PRIVILEGES GROUP BY GRANTEE,TABLE_SCHEMA ;
-- 表级别的权限
select GRANTEE,TABLE_SCHEMA,table_name,GROUP_CONCAT(PRIVILEGE_TYPE), concat("grant ",GROUP_CONCAT(PRIVILEGE_TYPE)," ON ",TABLE_SCHEMA,".",table_name," to " ,GRANTEE ) from information_schema.TABLE_PRIVILEGES GROUP BY GRANTEE,TABLE_SCHEMA,table_name ;
-- 列级别权限
select GRANTEE,TABLE_SCHEMA,table_name,COLUMN_NAME,GROUP_CONCAT(PRIVILEGE_TYPE) from information_schema.COLUMN_PRIVILEGES GROUP BY GRANTEE,TABLE_SCHEMA,table_name,COLUMN_NAME ;
-- 获取用户权限和密码(密文)
select a.GRANTEE,GROUP_CONCAT(a.PRIVILEGE_TYPE), concat("grant ",GROUP_CONCAT(a.PRIVILEGE_TYPE)," ON *.* to " ,a.GRANTEE ," identified by password '",c.authentication_string,"';" ) privi from USER_PRIVILEGES a left join mysql.user c on a.GRANTEE = concat("'",c.user,"'","@","'",c.host,"'") GROUP BY GRANTEE ;
对于以上关于mysql用户权限如何批量获取,大家是不是觉得非常有帮助。如果需要了解更多内容,请继续关注我们的行业资讯,相信你会喜欢上这些内容的。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。