title | summary | category | aliases | |
---|---|---|---|---|
SHOW GRANTS |
TiDB 数据库中 SHOW GRANTS 的使用概况。 |
reference |
|
SHOW GRANTS
语句用于显示与用户关联的权限列表。与在 MySQL 中一样,USAGE
权限表示登录 TiDB 的能力。
ShowStmt:
Username:
{{< copyable "sql" >}}
SHOW GRANTS;
+-------------------------------------------+
| Grants for User |
+-------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' |
+-------------------------------------------+
1 row in set (0.00 sec)
{{< copyable "sql" >}}
SHOW GRANTS FOR 'u1';
ERROR 1141 (42000): There is no such grant defined for user 'u1' on host '%'
{{< copyable "sql" >}}
CREATE USER u1;
Query OK, 1 row affected (0.04 sec)
{{< copyable "sql" >}}
GRANT SELECT ON test.* TO u1;
Query OK, 0 rows affected (0.04 sec)
{{< copyable "sql" >}}
SHOW GRANTS FOR u1;
+------------------------------------+
| Grants for u1@% |
+------------------------------------+
| GRANT USAGE ON *.* TO 'u1'@'%' |
| GRANT Select ON test.* TO 'u1'@'%' |
+------------------------------------+
2 rows in set (0.00 sec)
SHOW GRANTS
语句与 MySQL 完全兼容。如有任何兼容性差异,请在 GitHub 上提交 issue。