How to Open Port 3306 CentOS 7

To open port 3306 on CentOS 7, you can follow the steps below:

  1. Login to CentOS 7 server with either root user or a user with sudo privileges.
  2. Open the firewall configuration file /etc/sysconfig/iptables or /etc/firewalld/zones/public.xml, depending on the firewall management tool you are using.
  3. If you are using iptables, please add the following rules to the file.
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

If you are using firewalld, please use the following command to add a rule:

sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent
sudo firewall-cmd --reload
  1. Save the file and exit.
  2. Reload the firewall configuration to apply the changes. If you are using iptables, use the following command:
sudo service iptables restart

If you are using firewalld, please use the following command:

sudo systemctl restart firewalld

You have successfully opened port 3306 now. Make sure that no other application is using port 3306, and ensure that your MySQL server is listening on that port.

bannerAds