Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SOLVED Open port 3306 (without CSF)

Discussion in 'Database Discussion' started by PatrickVeenstra, Apr 18, 2018.

  1. PatrickVeenstra

    PatrickVeenstra Well-Known Member

    Joined:
    Feb 12, 2012
    Messages:
    104
    Likes Received:
    3
    Trophy Points:
    68
    Location:
    Barcelona
    cPanel Access Level:
    Root Administrator
    I'm trying to connect remotely to my MySQL database, but port 3306 is closed (telnet can't connect). I guess it has something to do with the fact that I used to have CSF, but that isn't installed anymore (since months/years). Obviously I can't modify its configuration / settings.
    So installing the software did not undo everything it did.

    How can I re-open the MySQL port (or all ports) without CSF?
     
  2. cPanelLauren

    cPanelLauren Forums Analyst
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    836
    Likes Received:
    62
    Trophy Points:
    103
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hello,

    If the port was blocked on the server you'd be able to see it when listing the iptables rules in place. The following will show you the service and port number:
    Code:
    iptables -L -n
    You could open the port but I wouldn't recommend opening it, just allowing the IP of the remote server to access. If you're just using iptables (no CSF) you'd need to add something like what is listed in the following:
    Iptables. How to open a port to one ore more specific IP

    Though you'd change the port number to 3306 and the IP to your remote server's IP address.

    Thank you,
     
  3. PatrickVeenstra

    PatrickVeenstra Well-Known Member

    Joined:
    Feb 12, 2012
    Messages:
    104
    Likes Received:
    3
    Trophy Points:
    68
    Location:
    Barcelona
    cPanel Access Level:
    Root Administrator
    root@angels [~]# iptables -I INPUT -p tcp -s <IP-REMOVED> --dport 3306 -j ACCEPT
    [root@vmi174536 ~]# telnet <IP-REMOVED> 3306
    Trying <IP-REMOVED>...
    telnet: connect to address <IP-REMOVED>: Connection refused
     
    #3 PatrickVeenstra, Apr 18, 2018
    Last edited: Apr 18, 2018
  4. cPanelLauren

    cPanelLauren Forums Analyst
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    836
    Likes Received:
    62
    Trophy Points:
    103
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    it seems as though there's still a block, if you temporarily flush the iptabes rules with:


    Code:
    iptables --flush
    are you still unable to connect?

    You can reinitialize the rules by restarting iptables without saving in the flushed state.


    Thank you,
     
  5. PatrickVeenstra

    PatrickVeenstra Well-Known Member

    Joined:
    Feb 12, 2012
    Messages:
    104
    Likes Received:
    3
    Trophy Points:
    68
    Location:
    Barcelona
    cPanel Access Level:
    Root Administrator
    yes I am:
    Code:
    root@angels [~]# iptables --flush
    Code:
    [root@vmi174536 ~]# telnet <IP-REMOVED> 3306
    Trying <IP-REMOVED>...
    telnet: connect to address <IP-REMOVED>: Connection refused
     
  6. cPanelLauren

    cPanelLauren Forums Analyst
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    836
    Likes Received:
    62
    Trophy Points:
    103
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    This indicates that without any iptables rules in place the connection is still being blocked. That being said I would suggest that you check any hardware devices such as a router that may be connected to the server to ensure that the port is open in both as well. You may also want to contact your provider to ensure that they're not the source as well.


    Thank you,
     
  7. PatrickVeenstra

    PatrickVeenstra Well-Known Member

    Joined:
    Feb 12, 2012
    Messages:
    104
    Likes Received:
    3
    Trophy Points:
    68
    Location:
    Barcelona
    cPanel Access Level:
    Root Administrator
    Here's the fix, I'm glad I contacted official support at the same time:
    Code:
    # egrep 'bind|port|#skip-ne' /etc/my.cnf
    bind-address = 0.0.0.0
    port = 3306
    #skip-networking
     
  8. cPanelLauren

    cPanelLauren Forums Analyst
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    836
    Likes Received:
    62
    Trophy Points:
    103
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hello,


    Glad they were able to help you find a solution, it's always best if you open a ticket to allow them to look into the issue as it's much easier to identify the issue when you have access to the server and it eliminates any confusion with more than one person attempting to make changes.
     
Loading...

Share This Page