MySQL 9.0 版本資訊
REVOKE [IF EXISTS]
priv_type [(column_list)]
[, priv_type [(column_list)]] ...
ON [object_type] priv_level
FROM user_or_role [, user_or_role] ...
[IGNORE UNKNOWN USER]
REVOKE [IF EXISTS] ALL [PRIVILEGES], GRANT OPTION
FROM user_or_role [, user_or_role] ...
[IGNORE UNKNOWN USER]
REVOKE [IF EXISTS] PROXY ON user_or_role
FROM user_or_role [, user_or_role] ...
[IGNORE UNKNOWN USER]
REVOKE [IF EXISTS] role [, role ] ...
FROM user_or_role [, user_or_role ] ...
[IGNORE UNKNOWN USER]
user_or_role: {
user (see Section 8.2.4, “Specifying Account Names”)
| role (see Section 8.2.5, “Specifying Role Names”
}
REVOKE INSERT ON *.* FROM 'jeffrey'@'localhost';
REVOKE 'role1', 'role2' FROM 'user1'@'localhost', 'user2'@'localhost';
REVOKE SELECT ON world.* FROM 'role3';
REVOKE ALL PRIVILEGES, GRANT OPTION
FROM user_or_role [, user_or_role] ...
mysql> CREATE USER jerry@localhost; Query OK, 0 rows affected (0.01 sec) mysql> REVOKE SELECT ON test.t1 FROM jerry@localhost; ERROR 1147 (42000): There is no such grant defined for user 'jerry' on host 'localhost' on table 't1' mysql> REVOKE IF EXISTS SELECT ON test.t1 FROM jerry@localhost; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> SHOW WARNINGS\G *************************** 1. row *************************** Level: Warning Code: 1147 Message: There is no such grant defined for user 'jerry' on host 'localhost' on table 't1' 1 row in set (0.00 sec)
mysql> DROP USER IF EXISTS jerry@localhost; Query OK, 0 rows affected (0.01 sec) mysql> REVOKE SELECT ON test.t1 FROM jerry@localhost; ERROR 1147 (42000): There is no such grant defined for user 'jerry' on host 'localhost' on table 't1' mysql> REVOKE SELECT ON test.t1 FROM jerry@localhost IGNORE UNKNOWN USER; Query OK, 0 rows affected, 1 warning (0.01 sec) mysql> SHOW WARNINGS\G *************************** 1. row *************************** Level: Warning Code: 3162 Message: Authorization ID jerry does not exist. 1 row in set (0.00 sec)
# No such user, no such role mysql> DROP ROLE IF EXISTS Bogus; Query OK, 0 rows affected, 1 warning (0.02 sec) mysql> SHOW WARNINGS; +-------+------+----------------------------------------------+ | Level | Code | Message | +-------+------+----------------------------------------------+ | Note | 3162 | Authorization ID 'Bogus'@'%' does not exist. | +-------+------+----------------------------------------------+ 1 row in set (0.00 sec) # This statement attempts to revoke a nonexistent role from a nonexistent user mysql> REVOKE Bogus ON test FROM jerry@localhost; ERROR 3619 (HY000): Illegal privilege level specified for test # The same, with IF EXISTS mysql> REVOKE IF EXISTS Bogus ON test FROM jerry@localhost; ERROR 1147 (42000): There is no such grant defined for user 'jerry' on host 'localhost' on table 'test' # The same, with IGNORE UNKNOWN USER mysql> REVOKE Bogus ON test FROM jerry@localhost IGNORE UNKNOWN USER; ERROR 3619 (HY000): Illegal privilege level specified for test # The same, with both options mysql> REVOKE IF EXISTS Bogus ON test FROM jerry@localhost IGNORE UNKNOWN USER; Query OK, 0 rows affected, 2 warnings (0.01 sec) mysql> SHOW WARNINGS; +---------+------+--------------------------------------------+ | Level | Code | Message | +---------+------+--------------------------------------------+ | Warning | 3619 | Illegal privilege level specified for test | | Warning | 3162 | Authorization ID jerry does not exist. | +---------+------+--------------------------------------------+ 2 rows in set (0.00 sec)