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

这个异常是数据库只允许localhost或127.0.0.1访问,不允许远程访问。我用的本机IP都不行。

在数据库执行这三条SQL

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

host=%含义

%是通配符,host标识是设置允许访问的ip地址

例如:

  * host=localhost:只允许本机访问

  * host=169.254.18.%:只允许169.254.18.网段的可以访问

  * host=%:允许所有ip地址访问

 

最后:一定要重启MYSQL

Windows+R键:输入services.msc

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

 

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

上一篇:Oracle使用dblink连接SqlServer


下一篇:Mongodb内嵌文档索引创建问题