MySQL Revoke Privileges

When we give something, and when the time comes, it should be returned or some part of things we gave back to the owner or give up the things we possess.

Revoke works the same way as it is used to take back previously granted privileges. We can revoke SELECT, INSERT, UPDATE, DELETE, REFERENCES, ALTER, or ALL.

Syntax

REVOKE privileges ON object FROM user;

Privileges

  • Here are some of the privileges SELECT, INSERT, UPDATE, DELETE, INDEX, CREATE, ALTER, DROP, GRANT OPTION, and ALL.
  • In this, privileges revoke the power to take the ability to perform these queries off a user.

Example

  • If a user named john has all the privileges available granted to him.
  • One day, two specific privileges should be revoked on his table called accounts such as INSERT and SELECT.
REVOKE SELECT, INSERT ON accounts FROM 'john'@'localhost';

Simple as that.

  • Say now, for example, if we want to revoke all the privileges of john's accounts table, we can use this.
REVOKE ALL ON accounts FROM 'john'@'localhost';
  • Suppose there is a contact list of users and want to revoke UPDATE privileges off them. We can use this.
REVOKE UPDATE ON contacts FROM '*'@'localhost';

Conclusion:

So simple as that, this is how revoke works.

Fri, 07/15/2022 - 13:16
Ashwin possesses over five years of experience in the Quality Assurance industry and is currently serving as a Technical Lead at iVagus. His expertise encompasses a broad range of technologies, including Cypress, Rest Assured, Selenium, Cucumber, JavaScript and TypeScript.
Tags

Comments