1. Check centos version
cat /etc/redhat-release
2. Check the status of the firewall: active (running) is the open state
systemctl status firewalld
3. Add a firewall open port:
firewall-cmd --zone=public --add-port=3306/tcp --permanent
4. After opening the port, the firewall needs to be reloaded:
firewall-cmd --reload
5. Query whether the specified port is open
firewall-cmd --query-port=3306/tcp
Reference article linux firewalld firewall status query and open ports