java远程连接数据库

来源:互联网 发布:淘宝直播入口在哪 编辑:程序博客网 时间:2024/05/17 16:13


我在eclipse运行报的错,没报错就不管了。。。。

null, message from server: "Host '202.197.100.120' is not allowed toconnect to this MySQL server"

 

在服务器:

一:打开mysql控制台,输入:

1 use mysql;

2

3 show tables;


二:输入:

1 select host from user;

2

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


如果报错:

MySQL> updateuser set host='%' where user = 'root'; 
ERROR 1062(23000): Duplicate entry '%-root' for key 'PRIMARY' 
然后查看了下数据库的host信息如下: 
MySQL> selecthost from user where user = 'root'; 
+-----------------------+ 
| host | 
+-----------------------+ 
| % | 
| 127.0.0.1| 
|localhost.localdomain | 
+-----------------------+ 
3 rows in set(0.00 sec) 
host已经有了%这个值,所以直接运行命令: 
复制代码 代码如下:


MySQL>flushprivileges; 

 

原创粉丝点击