Show users with any privileges to database. MySQL

Michał Skóra picture Michał Skóra · Sep 22, 2011 · Viewed 58.2k times · Source

i have to select all users with any privileges to database (e.g. database 'mysql'). Any suggestions? Thanks.

Answer

Sukhjinder Singh picture Sukhjinder Singh · Mar 20, 2013

A good view of all users and their approximate privileges. If there is a password, it will by an encrytped string; if not, this field is blank. Select is a very general privlege; insert allows table manipulation within a database; shutdown allows major system changes, and should only be usable by root; the ability to grant permissions is separate from the others.

SELECT user, host, password, select_priv, insert_priv, shutdown_priv, grant_priv 
FROM mysql.user

View permissions for individual databases.

SELECT user, host, db, select_priv, insert_priv, grant_priv FROM mysql.db