【转】ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.165' (113)

原文转自:http://blog.csdn.net/chengyuqiang/article/details/54285857

1、程序报错

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link

2、尝试远程连接数据库

[[email protected] ~]# mysql -h192.168.1.165 -uroot -p123456

ERROR 2003 (HY000): Can‘t connect to MySQL server on ‘192.168.1.165‘ (113)

3、问题找到了,不能连接远程数据库

4、测试是否能ping到远程机器

[[email protected] ~]# ping 192.168.1.165

PING 192.168.1.165 (192.168.1.165) 56(84) bytes of data.

64 bytes from 192.168.1.165: icmp_seq=1 ttl=128 time=0.776 ms

64 bytes from 192.168.1.165: icmp_seq=2 ttl=128 time=1.26 ms

64 bytes from 192.168.1.165: icmp_seq=3 ttl=128 time=1.19 ms

^C

--- 192.168.1.165 ping statistics ---

3 packets transmitted, 3 received, 0% packet loss, time 2008ms

rtt min/avg/max/mdev = 0.776/1.078/1.268/0.215 ms

说明网络是连通的,再测试以下端口号

5、登录到数据库端

[[email protected] ~]# MySQL -uroot -p123456

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 11

Server version: 5.5.52-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

MariaDB [(none)]> select user,host,password from mysql.user;

+------+-----------+-------------------------------------------+

| user | host      | password                                  |

+------+-----------+-------------------------------------------+

| root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |

| root | 127.0.0.1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |

| root | ::1       | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |

+------+-----------+-------------------------------------------+

添加%

MariaDB [(none)]> grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘123456‘;

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;

Query OK, 0 rows affected (0.00 sec)

再次远程访问:

[[email protected] ~]# mysql -h192.168.1.165 -uroot -p123456

ERROR 2003 (HY000): Can‘t connect to MySQL server on ‘192.168.1.165‘ (113)

6、还是无法连接到数据库,可能不能访问端口号,再次测试

[[email protected] ~]# telnet 192.168.1.165 3306

Trying 192.168.1.165...

telnet: connect to address 192.168.1.165: No route to host

找到问题所在了,防火墙屏蔽了这个端口号。

7、直接关闭防火墙即可

[[email protected] ~]# systemctl disable firewalld

Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.

[[email protected] ~]# service firewalld stop

Redirecting to /bin/systemctl stop  firewalld.service

再次远程访问

[[email protected] ~]# telnet 192.168.1.165 3306

Trying 192.168.1.165...

telnet: connect to address 192.168.1.165: No route to host

[[email protected] ~]# mysql -h192.168.1.165 -uroot -p123456

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 7

Server version: 5.5.52-MariaDB MariaDB Server

Copyright (c) 2000, 2016, oracle, MariaDB Corporation Ab and others.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

MariaDB [(none)]>

成功了。

ERROR 2003 (HY000): Can‘t connect to MySQL server问题

解决办法总结:

1、确定远程机器的防火墙关闭,或在防火墙允许3306端口号

2、确定数据库允许远程访问,通过语句grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘123456‘即可。

【转】ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.165' (113)

时间: 2024-11-10 10:48:42

【转】ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.165' (113)的相关文章

ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.56.105' (113)

[[email protected] ~]# mysql -uroot -h192.168.56.105 -p Enter password: ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.56.105' (113) 问题的分析 出现上述问题,可能有以下几种可能 1. my.cnf 配置文件中 skip-networking 被配置 skip-networking 这个参数,导致所有TCP/IP端口没有被监听,也就是说

ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.33.10' (111) 解决方法

谷歌了一下之后,原来是在mysql的my.cnf中有下面一段代码: # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. bind-address = 127.0.0.1 #这里默认监听本地localhost 如果要让mysql监听到其他的地址,可以将bind-address = 127.0.0.1

Linux中mysql进入命令行报错:MYSQL ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.99.192' (111)

场景:在Linux中安装mysql01和mysql02,通过VIP虚出一个VIP=192.168.99.192,mysql01为主ip为192.168.99.153,mysql02为备机ip为192.168.99.154 此时VIP在mysql01上通过 mysql01上连接VIP :mysql -h 192.168.99.192 -P 3306   结果是可以正常进入mysql命令行: 通过mysql02上远程连接VIP 会在界面上报错:mysql error 2003(HY000):Can'

ERROR 2003 (HY000): Can't connect to MySQL server on "192.168.xxx.xxx" (111)

mac  homebrew 安装的mysql5.6 除本机外无法被其他ip的电脑访问. 网上查原因 有几个: 1.my.cnf配置中 查看是否有   bind-address = 127.0.0.1  和  skip-networking  前面加 #注释掉. 注意:homebrew安装的mysql有好几个配置文件,不确定的可以查找一下. sudo find / -name my.cnf #skip-networking #bind-address = 127.0.0.1 我的mac中找到4个,

mysql添加,授权,删除用户以及连接数据库Can't connect to MySQL server on '192.168.31.106' (113)错误排查

centos7下面操作mysql添加,授权,删除用户 添加用户 以root用户登录数据库,运行以下命令: create user test identified by '123456789'; 上面创建了用户test,密码是123456789.我们在mysql.user表里面可以看到新增的用户信息 +------+----------------+-------------------------------------------+ | user | host | password | +--

ERROR 2003 (HY000): Can't connect to MySQL server

一.问题的提出 /usr/local/webserver/mysql/bin/mysql -u root -h 172.29.141.112  -p -S /tmp/mysql.sockEnter password: ERROR 2003 (HY000): Can't connect to MySQL server on '172.29.141.112' (113) 二.问题的分析 出现上述问题,可能有以下几种可能 1. my.cnf 配置文件中 skip-networking 被配置 skip

ERROR 2003 (HY000): Can't connect to MySQL server on 'ip'(111)

问题描述:  从一台linux远程连接另一台linux上的MySQL, 出现ERROR 2003 (HY000): Can't connect to MySQL server on 'ip'(111)错误.   [[email protected] ~]$ mysql -hxxx.xxx.xxx.85 -uroot -p Enter password:  123456   ERROR 2003 (HY000): Can't connect to MySQL server on 'xxx.xxx.

[转]MySQL远程连接ERROR 2003 (HY000):Can't connect to MySQL server on'XXXXX'(111) 的问题

装了个navicat ,然后去连接mysql服务器,一直连不上,一开始以为是防火墙问题,后来防火墙都关闭, iptable服务关闭,还是不行,网上查了下:主要是因为设置了bind_address=127.0.0.1 原文引用: 问题描述: 从一台linux远程连接另一台linux上的MySQL, 出现ERROR 2003 (HY000): Can't connect to MySQL server on 'xxx.xxx.xxx.85'(111)错误. [mysql@vvmvcs0 ~]$ my

[MYSQL] 使用 mysql-5.6.10-win32 (MySQL 5.6纯净版 ) 出现ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

win : window 10 mysql : mysql-5.6.10-win32 (MySQL 5.6纯净版 ) download From : Qt开源社区 http://www.qter.org/portal.php?mod=view&aid=10  ( https://pan.baidu.com/s/1boJQvJh ) 使用 mysql-5.6.10-win32 (MySQL 5.6纯净版 ) 出现ERROR 2003 (HY000): Can't connect to MySQL