Home > Database > Mysql Tutorial > How to cancel all permissions in mysql

How to cancel all permissions in mysql

青灯夜游
Release: 2022-06-14 16:18:27
Original
3801 people have browsed it

In mysql, you can use the REVOKE statement to delete the permissions of a specified user (specified permissions or all permissions). The syntax to cancel all permissions is "REVOKE ALL PRIVILEGES, GRANT OPTION FROM user;". For the REVOKE statement to take effect, you must have the global CREATE USER permission or UPDATE permission of the MySQL database.

How to cancel all permissions in mysql

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.

In MySQL, you can use the REVOKE statement to delete some or all permissions of a user.

Delete all permissions of a specific user, the syntax format is as follows:

REVOKE ALL PRIVILEGES, GRANT OPTION FROM 用户;
Copy after login

You need to pay attention to the following points when deleting user permissions:

  • ## The #REVOKE syntax is similar to the GRANT statement, but has the opposite effect.

  • To use the REVOKE statement, you must have global CREATE USER permission or UPDATE permission on the MySQL database.

Example: Assume that the rfc user has SELECT, UPDATE, and DELETE permissions on the sample database.

To revoke all permissions from the rfc user, execute the following command:

REVOKE ALL PRIVILEGES, GRANT OPTION FROM rfc;
Copy after login

If rfc checks the user's permissions again, you will see that the rfc user has no permissions.

SHOW GRANTS FOR rfc; 

GRANT USAGE ON *.* TO 'rfc'@'%';
Copy after login
Note: USAGE permissions means there are no permissions in MySQL.

When the MySQL REVOKE command takes effect

The effect of the MySQL REVOKE statement depends on the permission level, as follows:

  • Changes to global privileges only take effect when the client connects to MySQL in subsequent sessions. Changes will not be applied to all currently connected users.

  • Apply changes to database permissions after the next USE statement.

  • Changes to table and column permissions will apply to all queries issued after the change.

[Related recommendations:

mysql video tutorial]

The above is the detailed content of How to cancel all permissions in mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template