2

I've recently set up an ubuntu server to host my site - I need to open up port 3306 for MySQL access on my server.

I'm currently using shorewall on my server - how can open incoming connections to 3306 in shorewall? - Here are my current rules (enabling incoming for 80/HTTP and 22/SSH).

ACCEPT        $FW        net        icmp
HTTP/ACCEPT   net        $FW
SSH/ACCEPT    net        $FW

What is the rule name for the MySQL port (3306). Also, is it possible to enable ports just by port not by a name?

2

You do not want to enable MySQL access from the Internet at large. There is no reason to do so. If you need access for development purposes, just use an ssh tunnel. For local applications, they will be able to access MySQL via socket or loopback without any firewall changes.

  • My server is also protected by an external firewall, this is just so I can manage it locally from a gui. – Alex Coplan Jan 3 '12 at 14:00
  • Actually, just realised my client supports connection via SSH, so this is definitely the way to go (as it would allow secure external connections as well) - could you explain in more detail about socket/loopback for local apps - I haven't attempted to connect to my db through php yet, should it work just fine by defualt if I just use localhost ?? – Alex Coplan Jan 3 '12 at 14:06
  • 1
    If you have skip-networking enabled in mysql, then you'll need to connect via the UNIX socket, which I believe php will do by default if you specify "localhost" as the database host. – EEAA Jan 3 '12 at 15:21
2

5th column is the destination port:

ACCEPT      net                     $FW     tcp     3306

As pointed out it's not a good idea to open your MySQL server to the entire world. At the very least you should limit access to a certain IP(-range):

ACCEPT      net:192.168.0.0/24      $FW     tcp     3306

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.