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

本文记录了一次MySQL远程连接失败的问题排查过程,包括检查网络连通性、验证用户权限、调整MySQL配置及防火墙设置等步骤,最终成功解决了无法远程访问MySQL服务器的问题。
[root@ora102 ~]# mysql -uroot -pchinabidding -h192.168.8.247
Warning: Using a password on the command line interface can be insecure.
排查问题:
1)网络是通的
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.8.247' (113)
[root@ora102 ~]# ping 192.168.8.247
PING 192.168.8.247 (192.168.8.247) 56(84) bytes of data.
64 bytes from 192.168.8.247: icmp_seq=1 ttl=64 time=0.510 ms
64 bytes from 192.168.8.247: icmp_seq=2 ttl=64 time=0.446 ms
64 bytes from 192.168.8.247: icmp_seq=3 ttl=64 time=0.475 ms
2)权限是没问题的
MySQL [(none)]> select host,user,password from mysql.user;
+-----------+------+-------------------------------------------+
| host | user | password |
+-----------+------+-------------------------------------------+
| localhost | root | *2548EFB13B516547C44482A519B886726A3B8E42 |
|%| root | *2548EFB13B516547C44482A519B886726A3B8E42 |
| 127.0.0.1 | root | *2548EFB13B516547C44482A519B886726A3B8E42 |
| ::1 | root | *2548EFB13B516547C44482A519B886726A3B8E42 |
3)vi /etc/my.cnfi 查看参数bind-address 是否设置成了 = 127.0.0.1
我压根没有设置这个参数,这个参数是默认是127.0.0.1,限制只能本地登录。
4)查看防火墙状态,如下,active的,防火墙的是开的。
bogon:root@~>service iptables status
Redirecting to /bin/systemctl status iptables.service
● iptables.service - IPv4 firewall with iptables
Loaded: loaded (/usr/lib/systemd/system/iptables.service; disabled; vendor preset: disabled)
Active: active (exited)since Wed 2017-12-06 15:01:37 CST; 2s ago
Process: 21617 ExecStop=/usr/libexec/iptables/iptables.init stop (code=exited, status=0/SUCCESS)
Process: 22369 ExecStart=/usr/libexec/iptables/iptables.init start (code=exited, status=0/SUCCESS)
Main PID: 22369 (code=exited, status=0/SUCCESS)
Dec 06 15:01:37 bogon systemd[1]: Starting IPv4 firewall with iptables...
Dec 06 15:01:37 bogon iptables.init[22369]: iptables: Applying firewall rules: [ OK ]
Dec 06 15:01:37 bogon systemd[1]: Started IPv4 firewall with iptables.
查看端口,然后尝试去远端telnet 这个端口是否是同的。
MySQL [(none)]> show global variables like 'port';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port | 3306 |
+---------------+-------+
1 row in set (0.00 sec)
telne果然是不通的
[root@ora102 ~]# telnet 192.168.8.247 3306
Trying 192.168.8.247...
telnet: connect to address 192.168.8.247: No route to host
在源段关闭防火墙:
bogon:root@~>service iptables stop
Redirecting to /bin/systemctl stop iptables.service
永久关闭:
bogon:root@~>chkconfig iptables on
再次在远程登陆,正常了。。。。
[root@ora102 ~]# mysql -uroot -pchinabidding -h192.168.8.247
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 21
Server version: 5.5.29-log Source distribution

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
至此问题解决。。。。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29654823/viewspace-2148357/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29654823/viewspace-2148357/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值