How do I open port 3306 with ufw?

Posted January 4, 2015 63k views

I just got finished installing mysql on my droplet. I have set up and opened ports 80,443,(ssh) without a hiccup. My only problem now is that even though my droplet says that 3306 is open, I can’t connect to it outside of ssh. It says that 3306/tcp is set to allow ANYWHERE but I still can’t connect to it, even after a complete restart.

  • Just an FYI, you should not forward MySQL outside of the machine it is on, especially not to

    something else not mentioned here is that you need to ensure that your mysql users GRANT PRIVILEGES commands allow the IP / hostnames you connect in through

  • On this case, I was testing an mysql client to manage a non production database. Though this was back in January.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

What IP address is MySQL listening on?

sudo netstat -plutn | grep 3306

If, then you will have to configure it to listen on all interfaces instead ( and your droplet’s IP address). Edit /etc/mysql/my.cnf and set bind-address to

bind-address =

Then, restart MySQL:

sudo service mysql restart

If you’re the only one who’s going to access MySQL externally, it’s recommended to keep it listening on and using an SSH tunnel instead as it’s much more secure:

In this article, you'll learn how to create a safe, encrypted tunnel between your computer and your VPS along with how to bypass limits in a corporate network, how to bypass NAT, etc.