Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Revoke all privileges for all users on a MySQL DB

Tags:

mysql

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 simple, but I'm surprised I haven't been able to find this anywhere.

like image 854
mlissner Avatar asked Mar 13 '11 04:03

mlissner


People also ask

How do I revoke user privileges?

In this syntax: First, specify a list of comma-separated privileges that you want to revoke from a user account after the REVOKE keyword. Second, specify the object type and privilege level of the privileges after the ON keyword; check it out the GRANT statement for more information on privilege level.

What is revoke privileges of MySQL?

REVOKE removes privileges, but does not remove rows from the mysql. user system table. To remove a user account entirely, use DROP USER .

How do I revoke a MySQL user?

The syntax for the revoking privileges on a function or procedure in MySQL is: REVOKE EXECUTE ON [ PROCEDURE | FUNCTION ] object FROM user; EXECUTE. The ability to execute the function or procedure is being revoked.

What is revoke all?

: to annul by recalling or taking back : rescind. revoke a will. : to bring or call back.


2 Answers

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'@'%';
like image 123
Iasmini Gomes Avatar answered Oct 11 '22 21:10

Iasmini Gomes


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.

like image 40
Matt Ball Avatar answered Oct 11 '22 21:10

Matt Ball