SHOW ROLES
Function Description
List meta-information of the roles created under your account, including role name, creator, creation time, and comment content.
Note: If you need to query the role you are currently using, use the select current_role() statement.
Function Syntax
> SHOW ROLES [LIKE 'pattern'];
Example
-- Show the roles under your account
mysql> show roles;
+---------------------------------------------------------------------------------------------+
| ROLE_NAME | CREATOR | CREATED_TIME | COMMENTS |
+---------------------------------------------------------------------------------------------+
| moadmin | 0 | 2023-04-19 06:37:58 | |
| public | 0 | 2023-04-19 06:37:58 | |
+---------------------------------------------------------------------------------------------+
2 rows in set (0.01 sec)
-- Create a new role rolex
mysql> create role role role;
Query OK, 0 rows affected (0.02 sec)
-- Check the roles under your account again
mysql> show roles;
+---------------------------------------------------------------------------------------------+
| ROLE_NAME | CREATOR | CREATED_TIME | COMMENTS |
+---------------------------------------------------------------------------------------------+
| rolex | 1 | 2023-04-19 06:43:29 | |
| moadmin | 0 | 2023-04-19 06:37:58 | |
| public | 0 | 2023-04-19 06:37:58 | |
+---------------------------------------------------------------------------------------------+
3 rows in set (0.01 sec)
-- Query the role you are currently using
mysql> select current_role();
+---------------------+
| current_role() |
+---------------------+
| moadmin |
+---------------------+
1 row in set (0.00 sec)