Search the MySQL manual:

4.5.7.7 SHOW GRANTS

SHOW GRANTS FOR user lists the grant commands that must be issued to duplicate the grants for a user.

mysql> SHOW GRANTS FOR root@localhost;
+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+

To list grants for the current session one may use CURRENT_USER() function (new in version 4.0.6) to find out what user the session was authenticated as. See section 6.3.6.2 Miscellaneous Functions.

User Comments

Posted by Alexander Amelkin on Tuesday February 4 2003, @8:44am[Delete] [Edit]

A nice command, but it lacks the ability to show grants for all the users, not just one.

Posted by Geir Svalland on Wednesday March 19 2003, @3:23am[Delete] [Edit]

Yes, that is exactly what I'm looking for too.
I'll like to list all users that have an mysql-account on my system and what, if any, privileges they have.
/Hasse.

Posted by [name withheld] on Thursday July 31 2003, @10:33am[Delete] [Edit]

execute "SELECT * FROM mysql.user;" (with proper rights) and you will have all the users with all the system wide grants. I hope it helps.

Add your own comment.