linux启动项目提示java.net.ConnectException: 拒绝连接 (Connection refused)或提示Host XXX is not allowed to connect to this MySQL server。

这是由于Mysql配置了不支持远程连接引起的。

1、在安装Mysql数据库的主机上登录root用户:

mysql -u root -p

3.依次执行如下命令:

use mysql;

select host from user where user=‘root‘;

可以看到当前主机配置信息为localhost.

4.将Host设置为通配符%

Host列指定了允许用户登录所使用的IP,比如user=root Host=192.168.1.1。这里的意思就是说root用户只能通过192.168.1.1的客户端去访问。 user=root Host=localhost,表示只能通过本机客户端去访问。而%是个通配符,如果Host=192.168.1.%,那么就表示只要是IP地址前缀为“192.168.1.”的客户端都可以连接。如果Host=%,表示所有IP都有连接权限。

注意:在生产环境下不能为了省事将host设置为%,这样做会存在安全问题,具体的设置可以根据生产环境的IP进行设置;

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

Host设置了“%”后便可以允许远程访问。

5.Host修改完成后记得执行flush privileges使配置立即生效

6、再次启动项目就可以连接成功了

原文地址:https://www.cnblogs.com/lzghyh/p/12390681.html

时间: 2024-08-24 11:18:04

linux启动项目提示java.net.ConnectException: 拒绝连接 (Connection refused)或提示Host XXX is not allowed to connect to this MySQL server。的相关文章

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

java.sql.SQLException: null,  message from server: "Host 'xxx' is not allowed to connect to this MySQL server": 表示该对象不是远程对象,不能通过该对象远程访问数据 解决: 方案一:改表: use mysql ;select user,host,password from user; update user set host = '%' where user='root'; 方

Error: Could not open client transport with JDBC Uri: jdbc:hive2://localhost:10000: java.net.ConnectException: 拒绝连接 (Connection refused) (state=08S01,code=0)

一:启动hiveserver2服务 二:启动beeline 三:连接hiveserver2(下面的1000000端口号适当改小写因为其超出最大端口号的范围建议改为10000) 如果启动不成功实现我们先检查以下两个文件配置是否正确 1)hadoop文件夹下面的core-site.xml中的内容 <property> <name>hadoop.proxyuser.zhang.hosts</name> <value>*</value> </pro

java.sql.SQLException: null, message from server: “Host ‘xxx’ is not allowed to connect

java.sql.SQLException: null, message from server: “Host ‘xxx’ is not allowed to connect 2014年06月29日 ⁄ 综合 ⁄ 共 637字 ⁄ 字号 小 中 大 ⁄ 评论关闭 java.sql.SQLException: null,  message from server: "Host 'xxx' is not allowed to connect to this MySQL server": j

ls: Call From hdoop2/192.168.18.87 to hdoop2:8020 failed on connection exception: java.net.ConnectException: 拒绝连接; For more details see

场景:  预发环境中,同事已经搭建了一套hadoop集群,由于版本与所需不符,所以需要替换版本 问题描述: 在配置文件都准确的情况下,启动hadoop,出现以下报错: 启动之前初始化:   初始化目录跟配置文件目录不一致 hdfs  namenode -format [[email protected] hadoop-2.8.5]# hadoop dfs -ls /DEPRECATED: Use of this script to execute hdfs command is deprecat

新部署的linux web服务器error Host ‘*.*.*.*’ is not allowed to connect to this MySQL server

最近上头交给我个任务,把WINDOWS平台下开发的网站,部署在LINUX环境上. 把mysql安装好了,所有表单都导入没问题,然后代码都放在tomcat下的webapps文件夹下了,主页 面可以正常显示,但有两个问题: 用户登录或注册的时候总是提示:Connecting to 192.168.2.109……(linux server的ip): 查看Tomcat  log文件catalina.out里有一堆 [WARN][2014-07-09 21:28:58,706][org.hibernate

远程连接mysql时,提示“is not allowed to connect to this MySQL server”的解决方法

ERROR 1130: Host '192.168.1.3′ is not allowed to connect to this MySQL server这是告诉你没有权限连接指定IP的主机,下面我们来看看解决办法. 处理方法有二个 1.(如何解决客户端与服务器端的连接(mysql) :xxx.xxx.xxx.xxx is not allowed to connect to this mysql serv ) 授权法.例如,你想myuser使用mypassword从任何主机连接到mysql服务器

远程连接MySQL提示 Host is not allowed to connect to this MySQL server

进入连接的主机修改系统数据库MySQL 下面的user表,把User= root(这里可能是其他你所需要连接的用户名)的这行数据的Host从localhost改为% 如下图: 修改完之后一定要重启MySQL服务,否则无效 services.msc 然后就可以远程连接至该数据库了,以下是我配置weblogic的jndi数据源远程连接测试

linux部署项目(Java项目+Tomcat+mysql)

项目做完了,要发布了,而Java的特长之一就是移植性好,面对着微软的XP的停止服务,Windows系统的"独裁",越来越多的商家选择了开源的免费的linux系统作为服务器.因为linux系统也有图形界面(虽然和Windows比起来很不一样),所以在图形界面中操作相对来说还是容易的,这就好比我们在Windows系统上部署项目一样,大部分人都是小Case.但是真正工作中,服务器都会在固定的机房,而且往往只有一台主机,更规模大一些的就是使用单片机,像摆书一样摆到机房的机器架上,而我们操作它的

启动Mysql服务提示Can’t connect to local MySQL server through socket的解决方法

启动Mysql服务常会提示下面错误: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' 这是由于修改mysql服务的了socket文件mysql.sock位置,而导致无法通过mysql socket文件连接到mysql服务引起的,具体解决办法如下: 1.查看mysql服务的socket文件位置:mysql socket文件的位置是在/etc/my.c