centos – 无法与MYSQL数据库建立远程连接

前端之家收集整理的这篇文章主要介绍了centos – 无法与MYSQL数据库建立远程连接前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
想要远程访问MysqL数据库,但在检查yougetsignal(dot)com时,我收到一条消息,说明端口3306已关闭.

配置:Fresh Server(安装了Zpanel的Centos 6.4 64位)

已采取的步骤:

>从my.cnf中删除了绑定地址
>尝试添加绑定地址作为服务器IP
>编辑了IPTABLES以保持端口打开.
>从路由器转发端口
>在/etc/my.cnf中添加了port = 3306
>停止了IPTABLES
>每次更改后都会重启几次mysqld
>更改后重新启动IPTABLES

到目前为止没有任何工作.

IP表:

  1. # Firewall configuration written by system-config-firewall
  2. # Manual customization of this file is not recommended.
  3. *filter
  4. :INPUT ACCEPT [0:0]
  5. :FORWARD ACCEPT [0:0]
  6. :OUTPUT ACCEPT [0:0]
  7. -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  8. -A INPUT -p icmp -j ACCEPT
  9. -A INPUT -i lo -j ACCEPT
  10. -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
  11. -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
  12. -A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
  13. -A INPUT -j REJECT --reject-with icmp-host-prohibited
  14. -A FORWARD -j REJECT --reject-with icmp-host-prohibited
  15. COMMIT

诊断结果:
netstat结果:

  1. # netstat -na | grep 3306
  2. tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN

netstat结果(netstat -lnp | grep MysqL)

  1. # netstat -lnp | grep MysqL
  2. tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 6684/MysqLd
  3. unix 2 [ ACC ] STREAM LISTENING 33101 6684/MysqLd /var/lib/MysqL/MysqL.sock

iptables -L结果:

  1. Chain INPUT (policy ACCEPT)
  2. target prot opt source destination
  3. ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
  4. ACCEPT icmp -- anywhere anywhere
  5. ACCEPT all -- anywhere anywhere
  6. ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
  7. ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:http
  8. ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:https
  9. ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:MysqL
  10.  
  11. Chain FORWARD (policy ACCEPT)
  12. target prot opt source destination
  13. REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
  14.  
  15. Chain OUTPUT (policy ACCEPT)
  16. target prot opt source destination

可以从localhost / SSH连接在服务器上运行nc,但不能从远程系统运行

流量可能正在被过滤.

因为你提供了你的域名(假设在这里,尽管有两个不同的地址141.101.117.86有两个A记录是准确的..

跟踪到端口80,我们可以证明是开放的..

  1. $sudo traceroute -T -O info 141.101.117.86 -p 80
  2. traceroute to 141.101.117.86 (141.101.117.86),30 hops max,60 byte packets
  3. 1 192.168.1.1 (192.168.1.1) 0.332 ms 0.460 ms 0.574 ms
  4. 2 host-92-25-242-1.as13285.net (92.25.242.1) 13.745 ms 13.807 ms 13.902 ms
  5. 3 host-78-151-225-189.static.as13285.net (78.151.225.189) 15.058 ms 15.086 ms 15.118 ms
  6. 4 host-78-151-225-196.static.as13285.net (78.151.225.196) 16.120 ms host-78-151-225-232.static.as13285.net (78.151.225.232) 15.748 ms host-78-151-225-184.static.as13285.net (78.151.225.184) 16.069 ms
  7. 5 host-78-144-11-115.as13285.net (78.144.11.115) 16.630 ms 16.579 ms host-78-144-11-109.as13285.net (78.144.11.109) 16.798 ms
  8. 6 195.66.225.179 (195.66.225.179) 16.728 ms 14.735 ms 14.707 ms
  9. 7 141.101.117.86 (141.101.117.86) <syn,ack> 14.713 ms 14.907 ms 14.887 ms

如果我们尝试3306 ..

  1. $sudo traceroute -T -O info 141.101.117.86 -p 3306
  2. traceroute to 141.101.117.86 (141.101.117.86),60 byte packets
  3. 1 192.168.1.1 (192.168.1.1) 0.343 ms 0.444 ms 0.624 ms
  4. 2 host-92-25-242-1.as13285.net (92.25.242.1) 13.225 ms 13.226 ms 13.233 ms
  5. 3 host-78-151-225-189.static.as13285.net (78.151.225.189) 14.736 ms 15.352 ms 15.347 ms
  6. 4 host-78-151-225-220.static.as13285.net (78.151.225.220) 15.492 ms host-78-151-228-37.as13285.net (78.151.228.37) 15.441 ms host-78-151-225-232.static.as13285.net (78.151.225.232) 15.350 ms
  7. 5 host-78-144-11-95.as13285.net (78.144.11.95) 16.140 ms host-78-144-11-119.as13285.net (78.144.11.119) 16.551 ms host-78-144-11-95.as13285.net (78.144.11.95) 16.463 ms
  8. 6 * * *
  9. 7 * * *
  10. 8 * * *
  11. 9 * * *
  12. 10 * * *
  13. ...

此主机的流量停止:195.66.225.179,这可能是防火墙并阻止流量.

猜你在找的CentOS相关文章