1227 – Access denied; you need (at least one of) the SYSTEM_USER privilege(s) for this operation
具有 root 权限的用户也报 SYSTEM_USER 权限不足,如何解决?看下面
MySQL8 Access denied 解决
MySQL8 版本中新增了一个 system_user 帐户类型,当我们新增一个用户 test,并用 root 用户对 test 进行密码修改的操作时,系统不会报错。
create user 'test'@'localhost' identified by 'test';
set password for 'test'@'localhost' = 'test1';
因为此时用户 test 还没有被授权。当用户 test 被授权后,再使用 root 对 test 修改密码:
grant all on *.* to 'test'@'localhost';
set password for 'test'@'localhost' = 'test1';
这个时候系统会报错:
ERROR 1227 (42000): Access denied; you need (at least one of) the SYSTEM_USER privilege(s) for this operation
查阅了一下官方文档,原因是由于 root 用户没有 SYSTEM_USER 权限,把权限加入后即可解决:
grant system_user on *.* to 'root';
然后再修改 test 密码即可。不因为 SYSTEM_USER 权限涉及到所有帐户操作,所以不仅是修改密码,修改帐户信息,授权等都会报这个错,解决方法同样是上面的操作。
正文完
发表至: Linux
2025-03-01