[英]Can't Connect to the remote MYSQL server via 3306 port
I have been spending over 6 hours trying to solve this problem.我已经花了 6 个多小时试图解决这个问题。 After installing mysql server, I obviously changed bind-address from 127.0.0.1 to 0.0.0.0.
安装 mysql 服务器后,我显然将 bind-address 从 127.0.0.1 更改为 0.0.0.0。 I also tried commenting it out.
我也尝试将其注释掉。 When I check open port status with Nmap, it shows like below:
当我使用 Nmap 检查开放端口状态时,它显示如下:
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000011s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
23/tcp open telnet
3306/tcp open mysql
so the 3306 port is definitely open.所以3306端口肯定是开放的。 However, when I try to connect the server from my other machine, it shows:
但是,当我尝试从另一台机器连接服务器时,它显示:
ERROR 2003 (HY000): Can't connect to MySQL server on '49.247.XXX.XXX' (61)
so I check it with telnet and the result is:所以我用 telnet 检查它,结果是:
telnet: connect to address 49.247.XXX.XXX: Connection refused
telnet: Unable to connect to remote host
so I go back to that server machine an check the status again with netstat and the result is like below:所以我 go 回到那台服务器机器,用 netstat 再次检查状态,结果如下:
❯ sudo netstat -tlpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 769/systemd-resolve
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 994/sshd
tcp6 0 0 :::22 :::* LISTEN 994/sshd
tcp6 0 0 :::23 :::* LISTEN 3355/xinetd
tcp6 0 0 :::3306 :::* LISTEN 4108/mysqld
I find the number 3306 so it must be open right?我找到了 3306 号,所以它必须是开放的,对吗? I even tried the "sudo ufw allow XXXX/tcp" command to make sure 3306 is open.
我什至尝试了“sudo ufw allow XXXX/tcp”命令以确保 3306 已打开。 However, I ran out of ideas as to what is missing.
但是,我对缺少的东西一无所知。 Does anyone have any idea what to look for or how to fix this?
有谁知道要寻找什么或如何解决这个问题? Thanks a lot in advance!
提前非常感谢!
You need to also set the firewalld.您还需要设置防火墙。
Install Firewalld and do the following:安装 Firewalld 并执行以下操作:
firewall-cmd --zone=public --add-port=3306/tcp \ --permanent
this will make sure 3306 is open and accepting.这将确保 3306 是开放和接受的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.