Home  >  Article  >  Database  >  How to delete user permissions in mysql under linux?

How to delete user permissions in mysql under linux?

青灯夜游
青灯夜游Original
2020-10-13 17:35:104824browse

In mysql under Linux, you can use the REVOKE statement to delete a user's permissions (this user will not be deleted). The syntax format is "REVOKE ALL PRIVILEGES, GRANT OPTION FROM user" to delete all the user's permissions.

How to delete user permissions in mysql under linux?

(Recommended tutorial: mysql video tutorial)

In MySQL, you can use the REVOKE statement to delete a user Certain permissions (this user will not be deleted) can ensure system security to a certain extent. For example, a database administrator can remove DELETE permissions if they feel that a user should not have them.

There are two syntax formats for using the REVOKE statement to delete permissions, as shown below:

1) The first one

Deletes certain users Specific permissions, the syntax format is as follows:

REVOKE priv_type [(column_list)]...
ON database.table
FROM user [, user]...

The parameters in the REVOKE statement have the same meaning as the parameters in the GRANT statement. Among them:

priv_type parameter indicates the type of permission;

  • column_list parameter indicates which columns the permission applies to. Without this parameter, it applies to the entire table;

  • The user parameter consists of user name and host name, in the format of "username'@'hostname'".

2) The second type

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

REVOKE ALL PRIVILEGES, GRANT OPTION FROM user [, user] ...

Delete user permissions The following points need to be noted:

  • The syntax format of REVOKE syntax is similar to that of the GRANT statement, but they have opposite effects.

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

Example

Use the REVOKE statement to cancel the insert permission of user testUser. The SQL statement and execution process are as follows.

mysql> REVOKE INSERT ON *.*
    -> FROM 'testUser'@'localhost';
Query OK, 0 rows affected (0.01 sec)
mysql> SHOW GRANTS FOR 'testUser'@'localhost';
+-----------------------------------------------------------------+
| Grants for testUser@localhost                                   |
+-----------------------------------------------------------------+
| GRANT SELECT ON *.* TO 'testUser'@'localhost' WITH GRANT OPTION |
+-----------------------------------------------------------------+
1 row in set (0.00 sec)

The results show that the INSERT permission of the testUser user was successfully deleted.

The above is the detailed content of How to delete user permissions in mysql under linux?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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