java.sql.SQLException: null, message from server: "Host 'XXX' is not allowed to connect to this MySQL server"

 

 原因是:远程服务器不允许你的java程序访问它的数据库。所以,我们要对远程服务器进行设置,使它允许你进行连接。

解决步骤

1、打开mysql控制台,输入:use mysql;

 

 2、输入:show tables;

3、输入:select host from user;

 

4、输入:update user set host ='%' where user ='root';

 5、重启服务就可以连上了

 

posted @ 2020-03-18 10:57  killer21  阅读(2373)  评论(0编辑  收藏  举报