Why can't I telnet to mysql port 3306?

Linode Staff

I have configured in my.cnf and turned off the firewall but it doesn't work. I just created 3 VPS using CentOS 8, seems to have the same problem.

1 Reply

If you're trying to reach mysql over port 3306 from an external location, then yes, you'll need change the bind address in my.cnf, similar to what's outlined here:

https://serverfault.com/a/586656

Try to add bind-address = 0.0.0.0 to your [mysqld] section of your my.cnf and restart mysqld.
/etc/mysql/mysql.conf.d/mysqld.cnf

I just tested this out and it worked successfully. You mentioned you did this, but just to confirm: Add bind-address = 0.0.0.0, like it mentions, and also comment out bind-address = 127.0.0.1 by placing the # in front:

[mysqld]

bind-address = 0.0.0.0
# bind-address          = 127.0.0.1

Then after restart mysql with sudo systemctl restart mysql, you should be able to telnet from an external server.

telnet 192.53.115.99 3306
Trying 192.53.115.99...
Connected to 192-53-115-99.ip.linodeusercontent.com.
Escape character is '^]'.


nmap -Pn -p3306 192.53.115.99
Starting Nmap 7.92 ( https://nmap.org ) at 2021-11-26 12:36 EST
Nmap scan report for 192-53-115-99.ip.linodeusercontent.com (192.53.115.99)
Host is up (0.39s latency).

PORT     STATE SERVICE
3306/tcp open  mysql

Nmap done: 1 IP address (1 host up) scanned in 0.51 seconds

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct