• REVOKE
    • 语法图
    • 示例
    • MySQL 兼容性
    • 另请参阅

    REVOKE

    REVOKE <privileges> 语句用于删除已有用户的权限。

    语法图

    GrantStmt:

    GrantStmt

    PrivElemList:

    PrivElemList

    PrivElem:

    PrivElem

    PrivType:

    PrivType

    ObjectType:

    ObjectType

    PrivLevel:

    PrivLevel

    UserSpecList:

    UserSpecList

    示例

    1. mysql> CREATE USER newuser IDENTIFIED BY 'mypassword';
    2. Query OK, 1 row affected (0.02 sec)
    3. mysql> GRANT ALL ON test.* TO 'newuser';
    4. Query OK, 0 rows affected (0.03 sec)
    5. mysql> SHOW GRANTS FOR 'newuser';
    6. +-------------------------------------------------+
    7. | Grants for newuser@% |
    8. +-------------------------------------------------+
    9. | GRANT USAGE ON *.* TO 'newuser'@'%' |
    10. | GRANT ALL PRIVILEGES ON test.* TO 'newuser'@'%' |
    11. +-------------------------------------------------+
    12. 2 rows in set (0.00 sec)
    13. mysql> REVOKE ALL ON test.* FROM 'newuser';
    14. Query OK, 0 rows affected (0.03 sec)
    15. mysql> SHOW GRANTS FOR 'newuser';
    16. +-------------------------------------+
    17. | Grants for newuser@% |
    18. +-------------------------------------+
    19. | GRANT USAGE ON *.* TO 'newuser'@'%' |
    20. +-------------------------------------+
    21. 1 row in set (0.00 sec)
    22. mysql> DROP USER newuser;
    23. Query OK, 0 rows affected (0.14 sec)
    24. mysql> SHOW GRANTS FOR newuser;
    25. ERROR 1141 (42000): There is no such grant defined for user 'newuser' on host '%'

    MySQL 兼容性

    REVOKE <privileges> 语句与 MySQL 完全兼容。如有任何兼容性差异,请在 GitHub 上提交 issue。

    另请参阅

    • GRANT
    • SHOW GRANTS
    • Privilege Management