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

Web design and production test questions and reference answers

<br />Web Design and Production Test Part I ...

Summary of Docker common commands and tips

Installation Script Ubuntu / CentOS There seems t...

How to install JDK and Mysql on Ubuntu 18.04 Linux system

Platform deployment 1. Install JDK step1. Downloa...

HTML head tag detailed introduction

There are many tags and elements in the HTML head ...

Example of how to increase swap in CentOS7 system

Preface Swap is a special file (or partition) loc...

How to modify Flash SWF files in web pages

I think this is a problem that many people have en...

Native JS to implement sharing sidebar

This article shares a sharing sidebar implemented...

How to use async await elegantly in JS

Table of contents jQuery's $.ajax The beginni...

How to Clear Disk Space on CentOS 6 or CentOS 7

Following are the quick commands to clear disk sp...

How to use docker+devpi to build local pypi source

Some time ago, I needed to use pip downloads freq...

An article teaches you how to use js to achieve the barrage effect

Table of contents Create a new html file: Create ...