DavidSzczesniak
2/19/2018 - 12:42 PM

Revoking Privileges

The REVOKE statement is used to selectively revoke user privileges.

\!h Revoke the SELECT privilege from the user partmusic@localhost for the 'time' column in the 'track' table, inside the 'music' db:
REVOKE SELECT (time) ON music.track FROM 'partmusic'@'localhost'; -- very similar to GRANT syntax

\!h To remove all database-, table-, and column-level privileges at once:
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'partmusic'@'localhost';

-- alternative - removes privilages across the whole server
REVOKE ALL PRIVILEGES ON *.* FROM 'allmusic'@'localhost'; -- doesn't revoke GRANT OPTION privileges

-- to limit the above to the music db, use music.* as opposed to *.*

\!h To completely remove access to a database (in this case, all 'test' dbs):
REVOKE ALL ON test.* FROM ''@'%';

REVOKE ALL ON `test\_%`.* FROM ''@'%'; -- backquotes so the symbols after 'test' don't confuse MySQL