MyBatis3 连接MySQL8 提示:message from server: “Host ‘xxx‘ is not allowed to connect to this MySQL server

Posted 在奋斗的大道

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MyBatis3 连接MySQL8 提示:message from server: “Host ‘xxx‘ is not allowed to connect to this MySQL server相关的知识,希望对你有一定的参考价值。

今天在一台云服务器上部署应用,提示如下错误信息:

message from server: "Host 'xxx' is not allowed to connect to this mysql server

造成上述的错误的原因:

数据库连接的账户不允许从远程登陆,只允许使用localhost连接。

解决办法:

1、修改mysql数据库中的 "user" 表里的 "host" 字段,从"localhost"改称"%"

实列:
update user set host = '%' where user = 'root';

2、允许root用户使用123456密码从任何主机连接到mysql服务器。

MySQL > GRANT   ALL   PRIVILEGES   ON   *.*   TO   'root'@'%'   WITH   GRANT   OPTION
MySQL > FLUSH   PRIVILEGES //修改生效 

以上是关于MyBatis3 连接MySQL8 提示:message from server: “Host ‘xxx‘ is not allowed to connect to this MySQL server的主要内容,如果未能解决你的问题,请参考以下文章