USER_PRIVILEGES

USER_PRIVILEGES 表提供了关于全局权限的信息。该表的数据根据 mysql.user 系统表生成。

  1. USE information_schema;
  2. DESC user_privileges;
  1. +----------------+--------------+------+------+---------+-------+
  2. | Field | Type | Null | Key | Default | Extra |
  3. +----------------+--------------+------+------+---------+-------+
  4. | GRANTEE | varchar(81) | YES | | NULL | |
  5. | TABLE_CATALOG | varchar(512) | YES | | NULL | |
  6. | PRIVILEGE_TYPE | varchar(64) | YES | | NULL | |
  7. | IS_GRANTABLE | varchar(3) | YES | | NULL | |
  8. +----------------+--------------+------+------+---------+-------+
  9. 4 rows in set (0.00 sec)
  1. SELECT * FROM user_privileges;
  1. +------------+---------------+-------------------------+--------------+
  2. | GRANTEE | TABLE_CATALOG | PRIVILEGE_TYPE | IS_GRANTABLE |
  3. +------------+---------------+-------------------------+--------------+
  4. | 'root'@'%' | def | Select | YES |
  5. | 'root'@'%' | def | Insert | YES |
  6. | 'root'@'%' | def | Update | YES |
  7. | 'root'@'%' | def | Delete | YES |
  8. | 'root'@'%' | def | Create | YES |
  9. | 'root'@'%' | def | Drop | YES |
  10. | 'root'@'%' | def | Process | YES |
  11. | 'root'@'%' | def | References | YES |
  12. | 'root'@'%' | def | Alter | YES |
  13. | 'root'@'%' | def | Show Databases | YES |
  14. | 'root'@'%' | def | Super | YES |
  15. | 'root'@'%' | def | Execute | YES |
  16. | 'root'@'%' | def | Index | YES |
  17. | 'root'@'%' | def | Create User | YES |
  18. | 'root'@'%' | def | Trigger | YES |
  19. | 'root'@'%' | def | Create View | YES |
  20. | 'root'@'%' | def | Show View | YES |
  21. | 'root'@'%' | def | Create Role | YES |
  22. | 'root'@'%' | def | Drop Role | YES |
  23. | 'root'@'%' | def | CREATE TEMPORARY TABLES | YES |
  24. | 'root'@'%' | def | LOCK TABLES | YES |
  25. | 'root'@'%' | def | CREATE ROUTINE | YES |
  26. | 'root'@'%' | def | ALTER ROUTINE | YES |
  27. | 'root'@'%' | def | EVENT | YES |
  28. | 'root'@'%' | def | SHUTDOWN | YES |
  29. | 'root'@'%' | def | RELOAD | YES |
  30. | 'root'@'%' | def | FILE | YES |
  31. | 'root'@'%' | def | CONFIG | YES |
  32. +------------+---------------+-------------------------+--------------+
  33. 28 rows in set (0.00 sec)

USER_PRIVILEGES 表中列的含义如下:

  • GRANTEE:被授权的用户名称,格式为 'user_name'@'host_name'
  • TABLE_CATALOG:表所属的目录的名称。该值始终为 def
  • PRIVILEGE_TYPE:被授权的权限类型,每行只列一个权限。
  • IS_GRANTABLE:如果用户有 GRANT OPTION 的权限,则为 YES,否则为 NO