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

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

远程连接mysql数据库,出现异常:

null,message from server:"Host '27,45,38,132' is not allowed to connect

解决方案:

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

1,打开cmd命令窗口,进入MySQL安装目录的bin目录,然后登录MySQL

mysql -u root -p

2,输入:切入mysql数据库

use mysql;

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

3,输入:查看user表

select host,user from user;

4,输入:更改host字段值

update user set host ='%' where user ='root';

5,输入:即时生效

flush privileges; 

6,如果还是没效果,再次输入:创建远程登陆用户并授权:

grant all PRIVILEGES on msyql.* to root@'192.168.1.101'  identified by '';
grant all PRIVILEGES on sys.* to root@'192.168.1.101' identified by '';

或者

grant all PRIVILEGES on *.* to root@'192.168.1.101'  identified by '';

上面的语句表示将 test_db 数据库的所有权限授权给 root 这个用户,允许 root 用户在 192.168.1.101 这个 IP 进行远程登陆,并设置 root 用户的密码为 123456 。

7,输入:即时生效

flush privileges; 
上一篇:dea创建Maven工程用c3p0连接数据库报错java.sql.SQLException: Connections could not be acquired from the underlying


下一篇:反射报错java.lang.IllegalArgumentException: wrong number of arguments