centos7 開放3306埠並可以遠端訪問

2021-10-05 11:52:13 字數 1105 閱讀 1977

開啟遠端訪問:

允許任何ip以root使用者登入

grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;

flush privileges;#立即生效

centos 7.0預設使用的是firewall作為防火牆,這裡改為iptables防火牆。

1、關閉firewall:

systemctl stop firewalld.service

systemctl disable firewalld.service

systemctl mask firewalld.service

2、安裝iptables防火牆

yum install iptables-services -y
3.啟動設定防火牆

# systemctl enable iptables

# systemctl start iptables

4.檢視防火牆狀態

systemctl status iptables
5編輯防火牆,增加埠

vi /etc/sysconfig/iptables
#編輯防火牆配置檔案

-a input -m state --state new -m tcp -p tcp --dport 22 -j accept

-a input -m state --state new -m tcp -p tcp --dport 80 -j accept

-a input -m state --state new -m tcp -p tcp --dport 3306 -j accept

:wq! #儲存退出

3.重啟配置,重啟系統

systemctl restart iptables.service #重啟防火牆使配置生效

systemctl enable iptables.service #設定防火牆開機啟動

CentOS 7 開放3306埠訪問

centos 7.0預設使用的是firewall作為防火牆,這裡改為iptables防火牆。1 關閉firewall systemctl stop firewalld.service systemctl disable firewalld.service systemctl mask firewal...

CentOS 7 開放3306埠訪問

centos 7.0預設使用的是firewall作為防火牆,這裡改為iptables防火牆。1 關閉firewall systemctl stop firewalld.service systemctl disable firewalld.service systemctl mask firewal...

CentOS 7 開放3306埠訪問

centos 7.0預設使用的是firewall作為防火牆,這裡改為iptables防火牆。1 關閉firewall systemctl stop firewalld.service systemctl disable firewalld.service systemctl mask firewal...