Mysql报错java.sql.SQLException:null,message from server:"Host '*********' is not allowed to connect

场景:java连接数据库的时候报错:java.sql.SQLException:null,message from server:"Host '*********' is not allowed to connect;

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

解决方法:

1.打开MySQL的控制台,输入use mysql;

Mysql报错java.sql.SQLException:null,message from server:"Host '*********' is not allowed to connect

2.输入:update user set host ='%' where user ='root';

Mysql报错java.sql.SQLException:null,message from server:"Host '*********' is not allowed to connect

3.select host from user;

Mysql报错java.sql.SQLException:null,message from server:"Host '*********' is not allowed to connect

4.重启服务,ok。