View grants in MySQL

后端 未结 6 1470
轮回少年
轮回少年 2020-12-13 13:29

How do I view the grants (access rights) for a given user in MySQL?

6条回答
  •  余生分开走
    2020-12-13 13:57

    An alternative method for recent versions of MySQL is:

    select * from information_schema.user_privileges where grantee like "'user'%";
    

    The possible advantage with this format is the increased flexibility to check "user's" grants from any host (assuming consistent user names) or to check for specific privileges with additional conditions (eg, privilege_type = 'delete').

    This version is probably better suited to use within a script while the "show grants" syntax is better for interactive sessions (more "human readable").

提交回复
热议问题