【MYSQL】如何解决 java.sql.SQLException:null,message from Server:"Host 'xxx' is not allowed to connect to this MySQL Server"?
关键词:Host is not allowed to connect to this MySQL server.
问题发生:
url中机器地址写127.0.0.1或是localhost时不会发生,但写真实IP就出现此异常,即使从本机运行也会出此错。
解决方案:
登录MySQL控制台,执行以下命令:
mysql> use mysql; Database changed mysql> update user set host='%' where user='root'; Query OK, 1 row affected (0.04 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> flush privileges; Query OK, 0 rows affected (0.02 sec)
END
PS:凡是软件要写环回地址的地方,换成本机真实IP试试,会比原来多收获些东西。
- 上一篇 »报错--->java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delect from testd
- 下一篇 »java.sql.SQLException: No value specified for parameter 2 at com.mysql.jdbc.SQLError.create 小Bug异常