Viewing a User s Privileges


Viewing a User's Privileges

SHOW GRANTS; SHOW GRANTS FOR user; 



The SHOW GRANTS command can be used to ascertain what privileges a user has. The output is a list of GRANT statements that can be used to reproduce the same permissions if you had to assign them to the user again.

SHOW GRANTS FOR 'zak'@'localhost'; 


The result might look something like this:

+----------------------------------------------+ | Grants for zak@localhost                     | +----------------------------------------------+ | GRANT USAGE ON zakdb.* TO 'zak'@'localhost'  | | IDENTIFIED BY PASSWORD '57104f8717923cb5'    | | GRANT SELECT, INSERT ON `sampdb`.`mytable`   | | TO 'zak'@'localhost'                         | +----------------------------------------------+ 


Notice that this output indicates that a password has been set, but only an encrypted password is shown. You cannot decode this string back to the user's actual password.

Issuing SHOW GRANTS with no FOR clause shows the privileges for the current user. It is equivalent to

SHOW GRANTS FOR CURRENT_USER(); 




MySQL Phrasebook. Essential Code and Commands
MySQL Phrasebook
ISBN: 0672328399
EAN: 2147483647
Year: 2003
Pages: 130

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net