Name

SHOW GRANTS

Synopsis

SHOW GRANTS FOR user

This SQL statement displays the GRANTS statement for a given user. This is useful in duplicating an existing user’s privileges for another. If the username is given without reference to a particular host, the wildcard % is assumed. Otherwise, the username should be stated with the related host as shown here:

SHOW GRANTS FOR 'russell'@'localhost'\G
*************************** 1. row ***************************
Grants for russell@localhost: GRANT ALL PRIVILEGES ON *.* TO 
'russell'@'localhost' IDENTIFIED BY PASSWORD '1ajk6f3845a1bbca' 
WITH GRANT OPTION

To reduce clutter, this example is issued with \G instead of a semicolon to omit table formatting of the results. Notice that with the exception of the encrypted password in single quotes, the resulting statement is what would be entered to create the user russell for the host localhost, with the given privileges including the WITH GRANT OPTION flag.

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.