mysql The user specified as a definer ('XX'@'%') does not exist
Posted 四季常青
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql The user specified as a definer ('XX'@'%') does not exist相关的知识,希望对你有一定的参考价值。
测试组人员在做完数据库迁移后,项目运行后,发现有的sql报The user specified as a definer (‘XX‘@‘%‘) does not exist的错误。上网查询后发现是权限问题。
解决法案如下:
1.如果数据库中不存在xx用户,则创建xx用户
CREATE USER ‘XX‘@‘%‘ IDENTIFIED BY ‘password‘;
2.给xx授权
grant all privileges on *.* to [email protected]"%" identified by ".";
flush privileges;
创建用户命令:
CREATE USER ‘username‘@‘host‘ IDENTIFIED BY ‘password‘;
说明:username - 你将创建的用户名, host - 指定该用户在哪个主机上可以登陆,如果是本地用户可用localhost, 如果想让该用户可以从任意远程主机登陆,可以使用通配符%.
password - 该用户的登陆密码,密码可以为空,如果为空则该用户可以不需要密码登陆服务器。
授权命令:
GRANT privileges ON databasename.tablename TO ‘username‘@‘host‘ IDENTIFIED BY ‘mypassword‘ WITH GRANT OPTION;
说明:privileges - 用户的操作权限,如SELECT , INSERT , UPDATE 等。如果要授予所的权限则使用ALL。;databasename - 数据库名,tablename-表名,如果要授予该用户对所有数据库和表的相应操作权限则可用*表示, 如*.*。
IDENTIFIED BY ‘mypassword‘ 连接密码。
例子:如果你想允许用户myuser从ip为192.168.1.6的主机连接到mysql服务器,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON *.* TO ‘myuser‘@‘192.168.1.3‘ IDENTIFIED BY ‘mypassword‘ WITH GRANT OPTION;
FLUSH PRIVILEGES;
以上是关于mysql The user specified as a definer ('XX'@'%') does not exist的主要内容,如果未能解决你的问题,请参考以下文章
mysql的“The user specified as a definer (”@’%') does not exist”问题 解决
MySQL [Err]1449 : The user specified as a definer ('root'@'%') does not exist
mysql 1449 : The user specified as a definer ('root'@'%') does not e
mysql 1449 : The user specified as a definer ('root'@'%') does not exist 解决方法
[bug] MySQL: The user specified as a definer ('root'@'%') does not exist
MySQL错误:The user specified as a definer (XXX@XXX) does not exist