How do I list all users who ha开发者_高级运维ve DROP/DELETE privileges in mySQL?
select * from mysql.user where Delete_priv = 'Y' and Drop_priv = 'Y';
u can use show grants
SHOW GRANTS;
and see the users that have a delete/drop/all privileges
Note, that user's privileges can be granted at some levels.
-- Global level privileges
SELECT CONCAT(user, '@', host) FROM mysql.user WHERE delete_priv = 'Y' OR drop_priv = 'Y'
-- Table level privileges
SELECT CONCAT(user, '@', host) FROM mysql.tables_priv WHERE FIND_IN_SET('delete', table_priv) <> 0 OR FIND_IN_SET('drop', table_priv) <> 0
There also can be database level privileges (see mysql.db table).
精彩评论