当前位置:   article > 正文

MySQL8.0下给新建用户赋予 all privileges所有权限,然后撤销报错ERROR1227 : SYSTEM_USER privilege(s) for this operation_mysql> grant all privileges on *.* to 'newuser'@'%

mysql> grant all privileges on *.* to 'newuser'@'%' with grant option; error

赋予新用户所有权限(all privileges)

  1. mysql> grant all privileges on *.* to 'xiaokang'@'%' with grant option;
  2. Query OK, 0 rows affected (0.09 sec)

然后撤销用户所有权限(all privileges)

mysql> REVOKE all privileges ON *.* FROM 'xiaokang'@'%';

报错:

ERROR 1227 (42000): Access denied; you need (at least one of) the SYSTEM_USER privilege(s) for this operation

查看完MySQL8.0.16官方文档后得知: SYSTEM_USER是mysql新权限,并且在root用户下创建新用户xiaokang时会授予SYSTEM_USER权限,而自己却没有SYSTEM_USER权限。

得知原因后有以下两种办法:

方法1.现在新创建的用户下给root账户赋予SYSTEM_USER权限,然后在用root账户取消新用户xiaokang的所有权限

  1. # xiaokang用户下操作
  2. mysql> grant system_user on *.* to root;
  3. Query OK, 0 rows affected (0.06 sec)
  1. # root用户下的操作
  2. mysql> revoke all privileges on *.* from xiaokang;
  3. Query OK, 0 rows affected (0.02 sec)

可以看到xiaokang用户的所有权限撤销成功

 

方法2:直接在要撤销的账户(xiaokang)下操作

  1. # xiaokang用户下的操作
  2. mysql> revoke all privileges on *.* from xiaokang;
  3. Query OK, 0 rows affected (0.01 sec)

 

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/744773
推荐阅读
相关标签
  

闽ICP备14008679号