REVOKE

语法说明

将某个用户或者角色上被赋予的权限收回。

语法结构

  1. > REVOKE [IF EXISTS]
  2. priv_type [(column_list)]
  3. [, priv_type [(column_list)]] ...
  4. ON object_type priv_level
  5. > REVOKE [IF EXISTS] role [, role ] ...
  6. FROM user_or_role [, user_or_role ] ...

示例

  1. > CREATE USER mouser IDENTIFIED BY '111';
  2. Query OK, 0 rows affected (0.10 sec)
  3. > CREATE ROLE role_r1;
  4. Query OK, 0 rows affected (0.05 sec)
  5. > GRANT role_r1 to mouser;
  6. Query OK, 0 rows affected (0.04 sec)
  7. > GRANT create table on database * to role_r1;
  8. Query OK, 0 rows affected (0.03 sec)
  9. > SHOW GRANTS for mouser@localhost;
  10. +-------------------------------------------------------+
  11. | Grants for mouser@localhost |
  12. +-------------------------------------------------------+
  13. | GRANT create table ON database * `mouser`@`localhost` |
  14. | GRANT connect ON account `mouser`@`localhost` |
  15. +-------------------------------------------------------+
  16. 2 rows in set (0.02 sec)
  17. > REVOKE role_r1 from mouser;
  18. Query OK, 0 rows affected (0.04 sec)
  19. > SHOW GRANT for mouser@localhost;
  20. +------------------------------------------------+
  21. | Grants for mouser@localhost |
  22. +------------------------------------------------+
  23. | GRANT connect ON account `mouser`@`localhost` |
  24. +------------------------------------------------+
  25. 1 row in set (0.02 sec)