MySQL REVOKE to delete user permissions

MySQL REVOKE to delete user permissions

In MySQL, you can use the REVOKE statement to remove certain permissions of a user (the user will not be deleted), which can ensure the security of the system to a certain extent. For example, if the database administrator feels that a user should not have DELETE permission, then the DELETE permission can be removed.

There are two forms of syntax for removing permissions using the REVOKE statement, as follows:

1) The first type

Delete certain specific permissions of the user. 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. in:

  • The priv_type parameter indicates the type of permission;
  • The column_list parameter indicates which columns the permission applies to. If this parameter is not present, the permission applies to the entire table.
  • The user parameter consists of the username and host name in the format of "username'@'hostname'".

2) The second type

Delete all permissions for a specific user. The syntax is as follows:

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

When deleting user permissions, please note the following points:

  • The REVOKE syntax is similar to the GRANT statement syntax, but has the opposite effect.
  • To use the REVOKE statement, you must have the global CREATE USER privilege or the UPDATE privilege for the MySQL database.

Example 1

Use the REVOKE statement to revoke 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 result shows that the INSERT permission of the testUser user is deleted successfully.

This is the end of this article about MySQL REVOKE to delete user permissions. For more information about MySQL REVOKE to delete user permissions, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • A brief explanation of how to grant and revoke authorization in MySQL

<<:  iframe multi-layer nesting, unlimited nesting, highly adaptive solution

>>:  Detailed process of using Vscode combined with docker for development

Recommend

WeChat applet uses canvas to draw clocks

This article shares the specific code of using ca...

Instructions for using the database connection pool Druid

Replace it with the optimal database connection p...

Detailed steps to build an independent mail server on Centos7.9

Table of contents Preface 1. Configure intranet D...

How to use CSS attribute value regular matching selector (tips)

There are three types of attribute value regular ...

In-depth explanation of Session and Cookie in Tomcat

Preface HTTP is a stateless communication protoco...

Pure CSS to modify the browser scrollbar style example

Use CSS to modify the browser scroll bar style ::...

Summary of MySQL development standards and usage skills

1. Naming conventions 1. Database names, table na...

Introduction to root directory expansion under Linux system

1. Check Linux disk status df -lh The lsblk comma...

A practical record of checking and processing duplicate MySQL records on site

Table of contents Preface analyze Data Total Repe...

Some points on using standard HTML codes in web page creation

The most common mistake made by many website desi...

Detailed code for adding electron to the vue project

1. Add in package.json "main": "el...

JavaScript to achieve tab switching effect

This article shares the specific code of JavaScri...