MySQL root用户不能为普通用户赋权限

2021-08-10 11:16:59 浏览数 (1)

MySQL root用户不能为普通用户赋权限, 报错:Error Code: 1044. Access denied for user ‘root’@’%’ to database

代码语言:javascript复制
mysql> select host,user,password,Grant_priv,Super_priv FROM mysql.user;
 -------------- --------- ------------------------------------------- ------------ ------------ 
| host         |   user     | Grant_priv | Super_priv |
 -------------- --------- ------------------------------------------- ------------ ------------ 
| 192.168.10.% | zzh   | N          | Y          |
| 192.168.10.% | he    | N          | Y          |
| 192.168.10.% | root  | Y          | Y          |
| localhost    | sdvv  | N          | N          |
| localhost    | root  | Y          | Y          |
| %            | root  | N          | Y          |
| 127.0.0.1    | root  | Y          | Y          |
| %            | sdvv  | N          | Y          |
 -------------- --------- ------------------------------------------- ------------ ------------ 

可以看到root远程授权的权限没有打开:

代码语言:javascript复制
 %            | root  | N   

赋值一下权限即可。

代码语言:javascript复制
update mysql.user set Grant_priv='Y', Super_priv='Y' where User='root';
flush privileges;

0 人点赞