Nick
Nick

Reputation: 143

Can't Connect to the remote MYSQL server via 3306 port

I have been spending over 6 hours trying to solve this problem. After installing mysql server, I obviously changed bind-address from 127.0.0.1 to 0.0.0.0. I also tried commenting it out. When I check open port status with Nmap, it shows like below:

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

❯ 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? I even tried the "sudo ufw allow XXXX/tcp" command to make sure 3306 is open. 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!

Upvotes: 4

Views: 3098

Answers (1)

Nick
Nick

Reputation: 156

You need to also set the firewalld.

Install Firewalld and do the following:

 firewall-cmd --zone=public --add-port=3306/tcp \ --permanent

this will make sure 3306 is open and accepting.

Upvotes: 3

Related Questions