简体   繁体   English

无法通过 3306 端口连接到远程 MYSQL 服务器

[英]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.

相关问题 即使 mysqld 在端口 3306 上运行,也无法连接到“localhost:3306”上的 MySQL 服务器 - Can't connect to MySQL server on 'localhost:3306' even though mysqld is running on port 3306 Django-默认端口0而不是3306-无法连接到'127.0.0.1'上的MySQL服务器(61) - Django - default port 0 instead of 3306 - Can't connect to MySQL server on '127.0.0.1' (61) 3306端口没有收听? 无法远程连接MySQL - Port 3306 not listening? Can't connect to MySQL remotely 无法打开端口3306进行远程连接 - Can't open port 3306 for remote connection 如何修复'无法连接到'localhost:3306'上的MySQL服务器'错误 - How to fix 'Can't connect to MySQL server on 'localhost:3306' error 如何修复 InterfaceError:2003:无法连接到“127.0.0.1:3306:3306”上的 MySQL 服务器(11001 getaddrinfo 失败) - How to fix InterfaceError: 2003: Can't connect to MySQL server on '127.0.0.1:3306:3306' (11001 getaddrinfo failed) 找不到 MySql 端口 3306 - Can't find MySql port 3306 无法启动MySQL,3306端口忙 - Can't start MySQL, port 3306 busy 无法连接到 localhost:3306 上的 mysql? - Can't connect to mysql on localhost:3306? 我更改端口号而不是3306时无法连接到mysql - Can't connect to mysql when I changed its port number rather than 3306
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM