Revoke privileges
After you grant privileges, you can revoke them from a user.
Prerequisites
-
The current user must have the privileges to be revoked (for example,
test1must have theSELECTprivilege on tablet1to revoke theSELECTprivilege ont1fromtest2) and theGRANT OPTIONprivilege. -
When you revoke the
ALL PRIVILEGESandGRANT OPTIONprivileges, the current user must have the globalGRANT OPTIONprivilege or theUPDATEandDELETEprivileges on the privilege table.
Considerations
-
When you revoke multiple privileges from a user, separate the privilege types with commas (,).
-
When you revoke privileges from multiple users, separate the usernames with commas (,).
-
The revocation operation does not cascade. For example, if user
test1grants certain privileges to usertest2, revoking privileges fromtest1does not also revoke the corresponding privileges fromtest2.
Examples
-
Revoke global privileges
Revoke the
INSERTandSELECTprivileges on all tables in all databases from usertest.REVOKE SELECT, INSERT ON *.* FROM 'test'; -
Revoke database-level privileges
Revoke the
INSERTandSELECTprivileges on all tables in databasedb1from usertest.REVOKE SELECT, INSERT ON db1 FROM 'test'; -
Revoke table-level privileges
Revoke the
INSERTandSELECTprivileges on tabletb1_namein databasedb1from usertest.REVOKE SELECT, INSERT ON db1.tb1_name FROM 'test'; -
Revoke column privileges in a table
Revoke the
SELECTprivilege on columnc1and theINSERTprivileges on columnsc1andc2in tabletb1_namein databasedb1from usertest.REVOKE SELECT(c1), INSERT (c1, c2) ON db1.tb1_name FROM test;
For more information about the REVOKE statement, see REVOKE.