Revoke all privileges for all users on a MySQL DB
From: http://dev.mysql.com/doc/refman/5.0/en/drop-database.html
...when a database is dropped, user privileges on the database are not automatically dropped.
So the question becomes, how do you revoke all privileges for all users on a MySQL DB? I imagine it's simpl开发者_如何学运维e, but I'm surprised I haven't been able to find this anywhere.
REVOKE ALL PRIVILEGES ON *.* FROM '<user_name>'@'localhost';
REVOKE ALL PRIVILEGES ON *.* FROM '<user_name>'@'%';
Eg.:
REVOKE ALL PRIVILEGES ON *.* FROM 'jeffrey'@'localhost';
REVOKE ALL PRIVILEGES ON *.* FROM 'jeffrey'@'%';
You can revoke all privileges for a specific user with this syntax:
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user [, user] ...
FLUSH PRIVILEGES;
which drops all global, database, table, column, and routine privileges for the named user or users
Not sure if there's a way to do this for all users at once, though.
REVOKE ALL PRIVILEGES FROM '%'@'%';
The above could be dangerous as i suppose it will delete all the privileges from all the users including root
Modify it to:
REVOKE ALL PRIVILEGES FROM 'user'@'localhost';
or
REVOKE ALL PRIVILEGES FROM 'user'@'%';
before execute
I suppose you can do:
REVOKE ALL PRIVILEGES FROM '%'@'%';
FLUSH PRIVILEGES;
(Don't modify MySQL tables directly)
精彩评论