PingKai Logo下载

REVOKE <privileges>

此语句用于从现有用户中撤销权限。执行此语句需要拥有 GRANT OPTION 权限以及所有你要撤销的权限。

从 v8.5.6 开始,TiDB 支持与 MySQL 兼容的列级权限管理机制。你可以在 REVOKE 中指定列名列表,例如 REVOKE SELECT(col2) ON test.tbl FROM 'user'@'host';。更多信息,请参见列级权限管理。

概要

RevokeStmt
REVOKE PrivElemList ON ObjectType PrivLevel FROM UserSpecList
PrivElemList
PrivElem ,
PrivElem
PrivType ( ColumnNameList )
PrivType
ALL PRIVILEGES ALTER ROUTINE CREATE USER TEMPORARY TABLES VIEW ROLE ROUTINE TRIGGER DELETE DROP ROLE PROCESS EXECUTE INDEX INSERT SELECT SUPER SHOW DATABASES VIEW UPDATE GRANT OPTION REFERENCES REPLICATION SLAVE CLIENT USAGE RELOAD FILE CONFIG LOCK TABLES EVENT SHUTDOWN
ObjectType
TABLE
PrivLevel
* . * Identifier . * Identifier
UserSpecList
UserSpec ,

示例

mysql> CREATE USER 'newuser' IDENTIFIED BY 'mypassword';
Query OK, 1 row affected (0.02 sec)

mysql> GRANT ALL ON test.* TO 'newuser';
Query OK, 0 rows affected (0.03 sec)

mysql> SHOW GRANTS FOR 'newuser';
+-------------------------------------------------+
| Grants for newuser@%                            |
+-------------------------------------------------+
| GRANT USAGE ON *.* TO 'newuser'@'%'             |
| GRANT ALL PRIVILEGES ON test.* TO 'newuser'@'%' |
+-------------------------------------------------+
2 rows in set (0.00 sec)

mysql> REVOKE ALL ON test.* FROM 'newuser';
Query OK, 0 rows affected (0.03 sec)

mysql> SHOW GRANTS FOR 'newuser';
+-------------------------------------+
| Grants for newuser@%                |
+-------------------------------------+
| GRANT USAGE ON *.* TO 'newuser'@'%' |
+-------------------------------------+
1 row in set (0.00 sec)

mysql> DROP USER 'newuser';
Query OK, 0 rows affected (0.14 sec)

mysql> SHOW GRANTS FOR 'newuser';
ERROR 1141 (42000): There is no such grant defined for user 'newuser' on host '%'

MySQL 兼容性

相关链接