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

    SHOW GRANTS

    SHOW GRANTS 语句用于显示与用户关联的权限列表。与在 MySQL 中一样,USAGE 权限表示登录 TiDB 的能力。

    语法图

    ShowStmt:

    ShowStmt

    Username:

    Username

    示例

    1. mysql> SHOW GRANTS;
    2. +-------------------------------------------+
    3. | Grants for User |
    4. +-------------------------------------------+
    5. | GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' |
    6. +-------------------------------------------+
    7. 1 row in set (0.00 sec)
    8. mysql> SHOW GRANTS FOR 'u1';
    9. ERROR 1141 (42000): There is no such grant defined for user 'u1' on host '%'
    10. mysql> CREATE USER u1;
    11. Query OK, 1 row affected (0.04 sec)
    12. mysql> GRANT SELECT ON test.* TO u1;
    13. Query OK, 0 rows affected (0.04 sec)
    14. mysql> SHOW GRANTS FOR u1;
    15. +------------------------------------+
    16. | Grants for u1@% |
    17. +------------------------------------+
    18. | GRANT USAGE ON *.* TO 'u1'@'%' |
    19. | GRANT Select ON test.* TO 'u1'@'%' |
    20. +------------------------------------+
    21. 2 rows in set (0.00 sec)

    MySQL 兼容性

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

    另请参阅

    • SHOW CREATE USER
    • GRANT