借助MySQL REVOKE语句,我们可以撤消MySQL用户的一项或多项或所有特权。它的语法如下-
REVOKE privilege_type [(column_list)] [, priv_type [(column_list)]]... ON [object_type] privilege_level FROM user [, user]...
上面语法的解释如下-
首先,我们需要在REVOKE关键字之后指定要从用户撤消的特权列表。我们需要用逗号分隔特权。
其次,我们需要在ON子句中指定撤销特权的特权级别。
第三,我们需要在FROM子句中指定要撤销特权的用户帐户。
在给定的示例中,我们将撤消用户abcd @ localhost的授予-
mysql> SHOW GRANTS FOR abcd@localhost; +---------------------------------------------------------------------+ | Grants for abcd@localhost | +---------------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'abcd'@'localhost' WITH GRANT OPTION | +---------------------------------------------------------------------+ 1 row in set (0.00 sec)
以下查询将撤消用户'abcd @ localhost'的授予-
mysql> REVOKE ALL PRIVILEGES,GRANT OPTION FROM abcd@localhost; mysql> SHOW GRANTS for abcd@localhost; +------------------------------------------+ | Grants for abcd@localhost | +------------------------------------------+ | GRANT USAGE ON *.* TO 'abcd'@'localhost' | +------------------------------------------+ 1 row in set (0.00 sec)