在mysql bench 客户端链接mysql时 出现拒绝访问

在mysql bench 客户端链接mysql时 出现拒绝访问

-----经过排查 是因为新安装的系统centos stream 9 的防火墙是开启的,且默认端口3306是关闭的,需要对该端口号进行开放。

就可以正确使用。

firewalld(centos7)

Centos7默认安装了firewalld,如果没有安装的话,可以使用 yum install firewalld firewalld-config进行安装。

1.启动防火墙

systemctl start firewalld 

2.禁用防火墙

systemctl stop firewalld

3.设置开机启动

systemctl enable firewalld

4.停止并禁用开机启动

sytemctl disable firewalld

5.重启防火墙

firewall-cmd --reload

6.查看状态

systemctl status firewalld或者 firewall-cmd --state

7.查看版本

firewall-cmd --version

8.查看帮助

firewall-cmd --help

9.查看区域信息

firewall-cmd --get-active-zones

10.查看指定接口所属区域信息

firewall-cmd --get-zone-of-interface=eth0

11.拒绝所有包

firewall-cmd --panic-on

12.取消拒绝状态

firewall-cmd --panic-off

13.查看是否拒绝

firewall-cmd --query-panic

14.将接口添加到区域(默认接口都在public)

firewall-cmd --zone=public --add-interface=eth0(永久生效再加上 --permanent 然后reload防火墙)

15.设置默认接口区域

firewall-cmd --set-default-zone=public(立即生效,无需重启)

16.更新防火墙规则

firewall-cmd --reload或firewall-cmd --complete-reload(两者的区别就是第一个无需断开连接,就是firewalld特性之一动态
添加规则,第二个需要断开连接,类似重启服务)

17.查看指定区域所有打开的端口

firewall-cmd --zone=public --list-ports

18.在指定区域打开端口(记得重启防火墙)

firewall-cmd --zone=public --add-port=80/tcp(永久生效再加上 --permanent)

说明:
–zone 作用域
–add-port=8080/tcp 添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章