Problem:
After installing mysql on CentOS 7, localhost can connect to log in to mysql normally, but remote access cannot connect. Tried ping and found that the ping was successful; tried telnet port and found that port 3306 was unreachable.
Solution:
You need to open port 3306 in the firewall configuration.
The command is as follows:
firewall-cmd --zone=public --add-port=3306/tcp --permanent (--permanent永久生效,没有此参数重启后失效) #重新载入 firewall-cmd --reload #查看 firewall-cmd --zone=public --query-port=3306/tcp vi /etc/sysconfig/iptables #添加 -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
Recommended related tutorials: centos tutorial
The above is the detailed content of After installing mysql on centos, port 3306 is blocked. For more information, please follow other related articles on the PHP Chinese website!