最近从一个库中的视图导出,向另一个库执行语句的时候 ,一直提示:
the user specified as a definer ('root'@'%') does not exist
网上查了下相关问题解决方法,基本都是这句
grant all privileges on *.* to root@"%" identified by ".";
实际运行报错
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by "."' at line 1
经过查询,实际问题
mysql8.0 以后这句的用法不一样了。
最后这样执行:
mysql> create user 'root'@'%' identified by '123456';
Query OK, 0 rows affected (0.07 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.03 sec)
最后再创建视图时,执行语句,就成功了。