mysql8.0版本 the user specified as a definer ('root'@'%') does not exist问题解决

叙述(可忽略,直接看下面的解决方法)

在修改数据库数据时,遇到the user specified as a definer ('root'@'%') does not exist错误

利用网上给的方法

grant all privileges on *.* to root@"%" identified by "Passwd"

提示语法错误

原因是mysql8.0 grant授权后面不用带identified by...

重新输入

grant all privileges on *.* to 'root'@'%';

再次报错

查询资料后,发现是版本的问题,8.0.11版本之后移除了grant 语句添加用户的功能,也就是说grant...只能适用于已存在的账户,不能通过 grant... 来添加账号了。

解决方法

mysql> create user 'root'@'%' identified by '密码';
Query OK, 0 rows affected (2.35 sec)
 
mysql> grant all privileges on *.* to 'root'@'%';
Query OK, 0 rows affected (0.06 sec)
 
mysql> flush privileges;
Query OK, 0 rows affected (0.06 sec)

本地处理

create user 'root'@'%' identified by '1234';

grant all privileges on *.* to 'root'@'%';

flush privileges;

end。

原文地址:https://www.cnblogs.com/xh_Blog/p/15569193.html