Home >Operation and Maintenance >CentOS >After installing mysql on centos, port 3306 is blocked

After installing mysql on centos, port 3306 is blocked

王林
王林Original
2020-04-03 13:48:324115browse

After installing mysql on centos, port 3306 is blocked

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn