Scenario: Someone wants to know which of the over 50 MySQL users
have certain privileges.
There are many ways to solve this problem. Some of these
scenarios are tedious and repetitious, others take no time at
all.
The issue, of course, lies in what the “certain” privileges are.
If it is “who has the SUPER privilege?” then a simple
SELECT user,host FROM mysql.user WHERE Super_priv='Y';
is sufficient. If it is “who has write access to the foo
database”, you might write:
SELECT user,host FROM db WHERE Db='foo' AND Select_priv='Y';
but that only shows who explicitly has read permissions on that
database; it does not include those who have global read
permissions. The full query would be:
(more…)