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

1、程序报错
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link
2、尝试远程连接数据库
[root@inode1 ~]# 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到远程机器

[root@inode1 ~]# 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、登录到数据库端

[root@dbServer ~]# 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)

再次远程访问:

[root@hadron ~]# mysql -h192.168.1.165 -uroot -p123456
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.165' (113)

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

[root@hadron ~]# telnet 192.168.1.165 3306
Trying 192.168.1.165...
telnet: connect to address 192.168.1.165: No route to host

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

7、直接关闭防火墙即可

[root@dbServer ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[root@dbServer ~]# service firewalld stop
Redirecting to /bin/systemctl stop  firewalld.service

再次远程访问

[root@hadron ~]# telnet 192.168.1.165 3306
Trying 192.168.1.165...
telnet: connect to address 192.168.1.165: No route to host
[root@hadron ~]# 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)的更多相关文章

  1. (一)MYSQL ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.10.210' (111) 解决方法

    今天在测试MySQL的连接时候,发现连接不通过,并报错ERROR 2003 (HY000): Can't connect to mysql server on '192.168.10.210' (11 ...

  2. MYSQL ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.10.210' (111) 解决方法

    今天在测试MySQL的连接时候,发现连接不通过,并报错ERROR 2003 (HY000): Can't connect to mysql server on '192.168.10.210' (11 ...

  3. 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  ...

  4. 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 ...

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

    http://blog.csdn.net/longxibendi/article/details/6363934 一.问题的提出 /usr/local/webserver/mysql/bin/mysq ...

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

    centos7下面操作mysql添加,授权,删除用户 添加用户 以root用户登录数据库,运行以下命令: create user test identified by '; 上面创建了用户test,密 ...

  7. ERROR 2003 (HY000): Can't connect to MySQL server on 'ip address' (111)的处理办法

    远程连接mysql数据库时可以使用以下指令 mysql -h 192.168.1.104 -u root -p 如果是初次安装mysql,需要将所有/etc/mysql/内的所有配置文件的bind-a ...

  8. mysql绿色版安装问题解决(ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061))

    原来一直是使用MySQL安装版没有出现过问题,今天在安装绿色版MySQL时出现了点问题 在安装成windows服务成功后,用net start mysql 启动时提示启动成功,但当我连接mysql就报 ...

  9. 【linux错误解决】MySQL远程连接ERROR 2003 (HY000):Can't connect to MySQL server on'XXXXX'的问题

    问题描述: 从一台linux远程连接另一台linux上的MySQL, 出现ERROR 2003 (HY000): Can't connect to MySQL server on 'xxx.xxx.x ...

随机推荐

  1. 【luogu P2827 蚯蚓】 题解

    题目链接:https://www.luogu.org/problemnew/show/P2827 35分:暴力sortO(mnlogn). 80分:考虑到每次不好维护不被切的点+q,正难则反.改成维护 ...

  2. [BJWC2018]最长上升子序列

    十分感谢GXZ大佬的讲解,此处致以敬意!emmmm在初学状压DP时就理解了如此精妙的一道题,感到很开森~ \(Address\) ________________ #\(\color{red}{\ma ...

  3. UIWebView 获取网页标题

    - (void)webViewDidFinishLoad:(UIWebView *)webView { NSString *urlString = webView.request.URL.absolu ...

  4. 用 S5PV210 学习 Linux (三) SD卡下载

    学习地址:http://edu.51cto.com/lesson/id-63015.html http://blog.csdn.net/karven_/article/details/52015325 ...

  5. page_address()函数分析--如何通过page取得虚拟地址

    由于X86平台上面,内存是划分为低端内存和高端内存的,所以在两个区域内的page查找对应的虚拟地址是不一样的. 一. x86上关于page_address()函数的定义 在include/linux/ ...

  6. iOS 第三方库、插件、知名博客总结

    iOS 第三方库.插件.知名博客总结 用到的组件 1.通过CocoaPods安装 项目名称 项目信息 AFNetworking 网络请求组件 FMDB 本地数据库组件 SDWebImage 多个缩略图 ...

  7. Java常用修饰符总结

    修饰符是用于限定类型以及类型成员申明的一种符号,可用于修饰类.变量和方法,分为访问修饰符和非访问修饰符.访问修饰符控制访问权限,不同的访问修饰符有不同的权限范围,而非访问修饰符则是提供一些特有功能. ...

  8. Java工具-----native2ascii

    概述 native2ascii.exe位于%JAVA_HOME/bin目录下,所以要使用,得先安装JDK. 该工具用来将本地编码转换为Unicode,英文字母.阿拉伯数字不会转化. 官方文档:http ...

  9. Delphi在Android下实现BroadcastReceiver功能(举例在Delphi下获取USB外设拔插消息)

    在Android里,用java通过实现BroadcastReceiver接口,就可以获得Intent消息.可是Delphi程序不能直接实现JBroadcastReceiver,如何能够实现类似Java ...

  10. 大数据时代数据库-云HBase架构&生态&实践

    业务的挑战 存储量量/并发计算增大 现如今大量的中小型公司并没有大规模的数据,如果一家公司的数据量超过100T,且能通过数据产生新的价值,基本可以说是大数据公司了 .起初,一个创业公司的基本思路就是首 ...