Important
New database features are no longer connected to engine versions; features are now enabled independently during scheduled update windows, and “major” and “minor” releases no longer exist in Helios. Please visit the release notes to view the latest features available in your database clusters.
SHOW GRANTS
On this page
The SHOW GRANTS command shows permissions (privileges) for the specified user (or role).
Syntax
SHOW GRANTS [FOR {user | role}]user:'user'@'host_name'role:ROLE 'role_name'
Arguments
-
'user'@'host_- user for which to show privileges.name' If a hostname is not specified, @'%'will be appended to the user string.For example, 'demo-user'is equivalent to'demo-user'@'%'.The '%'wildcard matches any hostname.userandhost_need not be quoted if they are legal as unquoted identifiers.name Quotes must be used if a host_string contains wildcard characters (such asname %), or a user string contains special characters (such as space or-) or is a restricted keyword. -
'role_- role for which to show privilegesname'
Example
The SHOW GRANTS command displays the privileges assigned to the current user.
SHOW GRANTS;
+---------------------------------------------------------------------+
| Grants for root@% |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' |
+---------------------------------------------------------------------+
+---------------------------------------------------------------------+
| Grants for user1@% |
+---------------------------------------------------------------------+
| GRANT SELECT, INSERT ON `mydb`.* TO 'user1'@' [WITH GRANT OPTION] |
| GRANT TRANSFERABLE SELECT, INSERT ON `mydb`.* TO 'user1'@'%' |
+---------------------------------------------------------------------+The SHOW GRANTS FOR command displays the privileges assigned to the specified user.
SHOW GRANTS FOR user1;
+---------------------------------------------------------------------+
| Grants for user1@% |
+---------------------------------------------------------------------+
| GRANT SELECT, INSERT ON `mydb`.* TO 'user1'@' [WITH GRANT OPTION] |
| GRANT TRANSFERABLE SELECT, INSERT ON `mydb`.* TO 'user1'@'%' |
+---------------------------------------------------------------------+Users with ALTER USER privilege can see the hashed password using the command SHOW GRANTS FOR <user>.
SHOW GRANTS FOR user1;
+--------------------------------------------------------------------------------------------------------------+
| Grants for user1@% |
+--------------------------------------------------------------------------------------------------------------+
| GRANT SHOW METADATA ON *.* TO 'user1'@'%' IDENTIFIED BY PASSWORD '*785FBD495FC22B3620EB1572D2504C03B1278554' |
+--------------------------------------------------------------------------------------------------------------+Users without ALTER USER privilege will not be able to see the hashed password.
SHOW GRANTS FOR user1;
+---------------------------------------------------------------------------+
| Grants for user1@% |
+---------------------------------------------------------------------------+
| GRANT SHOW METADATA ON *.* TO 'user1'@'%' IDENTIFIED BY PASSWORD <secret> |
+---------------------------------------------------------------------------+The SHOW GRANTS FOR ROLE command displays the grants assigned to the role specified in the query.rw
.
SHOW GRANTS FOR ROLE 'rw';
+---------------------------------------------------------------------------------+
| Grants for role rw |
+---------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO ROLE 'rw' |
| GRANT TRANSFERABLE SELECT, INSERT, UPDATE ON `trades`.`company` TO ROLE 'rw' |
+---------------------------------------------------------------------------------+Last modified: