Listing Users with Database Access

Programming 24 May 2009 | View Comments

As a part of my server migration, I’ve begun noting which databases to transfer, which I can trash, and who owns them. This is pretty eye-opening, as it lets me know which users I had forgotten to purge as they left my services.

SELECT User
FROM    mysql.db
WHERE  Db = 'databasename';

That will retrieve all of the users that have access to databasename. Thanks to Elazar (on Freenode) for this solution.

Only issue with this, is it doesn’t list the users who have global permissions (ie: *.*). Any ideas on solutions that would include that? Or is there not a “simpler” way.

Tagged in , , , , ,

blog comments powered by Disqus