Skip to content

Latest commit

 

History

History
61 lines (46 loc) · 1.8 KB

sql-statement-show-grants.md

File metadata and controls

61 lines (46 loc) · 1.8 KB
title summary aliases
SHOW GRANTS | TiDB SQL Statement Reference
An overview of the usage of SHOW GRANTS for the TiDB database.
/docs/dev/sql-statements/sql-statement-show-grants/
/docs/dev/reference/sql/statements/show-grants/

SHOW GRANTS

This statement shows a list of privileges associated with a user. As in MySQL, the USAGE privileges denotes the ability to login to TiDB.

Synopsis

ShowGrantsStmt ::=
    "SHOW" "GRANTS" ("FOR" Username ("USING" RolenameList)?)?

Username ::=
    "CURRENT_USER" ( "(" ")" )?
| Username ("@" Hostname)?

RolenameList ::=
    Rolename ("@" Hostname)? ("," Rolename ("@" Hostname)? )*

Examples

mysql> SHOW GRANTS;
+-------------------------------------------+
| Grants for User                           |
+-------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' |
+-------------------------------------------+
1 row in set (0.00 sec)

mysql> SHOW GRANTS FOR 'u1';
ERROR 1141 (42000): There is no such grant defined for user 'u1' on host '%'
mysql> CREATE USER u1;
Query OK, 1 row affected (0.04 sec)

mysql> GRANT SELECT ON test.* TO u1;
Query OK, 0 rows affected (0.04 sec)

mysql> 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)

MySQL compatibility

The SHOW GRANTS statement in TiDB is fully compatible with MySQL. If you find any compatibility differences, report a bug.

See also