您好,登錄后才能下訂單哦!
下文主要給大家帶來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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。