Open port 3306 on the virtual machine or close the firewall to achieve remote connection to MySQL

Commands for opening, closing, and disabling the firewall
Settings to enable/disable the firewall at startup:systemctl enable/disable firewalld.service
Enable/disable the firewall:systemctl start/stop firewalld
Check firewall status:systemctl status firewalld

1. Turn off the firewall of the Linux virtual machine (CentOS) to achieve remote connection to MySQL
(1) Temporary shutdown

service iptables stop

(2) Permanently closed
<1>

chkconfig iptables off

<2>

#查看firewall状态
systemctl status firewalld.service

#停止firewall
systemctl stop firewalld.service

#禁止firewall开机启动
systemctl disable firewalld.service

After closing the firewall, you can operate the remote connection

2. The Linux virtual machine (CentOS) opens port number 3306 to realize MySQL remote connection
(1) Check the firewall

systemctl status firewalld`

(2) Check the status of port 3306

firewall-cmd --zone=public --query-port=3306/tcp

(3) If it is no, it means closing and opening port 3306.

firewall-cmd --zone=public --add-port=3306/tcp --permanent 

(4) Firewall reload

firewall-cmd --reload

(5) Check the 3306 status again

firewall-cmd --zone=public --query-port=3306/tcp

After opening port 3306, you can operate MySQL remote connection

Guess you like

Origin blog.csdn.net/bigBbug/article/details/130138202