Linux开放端口号Linux开放端口号(mysql打开远程连接) )。
在Centos 7或RHEL 7或Fedora上,防火墙由防火墙d而不是iptables管理。
一.防火墙
语法命令启用区域端口和协议的组合
firewall-cmd [zone=]-- add-port=[-]/[time out=]
端口和协议的组合将生效。
端口可以是单独的端口或端口范围。
协议可以是tcp或udp。
查看防火墙d状态
系统状态文件d
开放端口:
//--permanent永久有效,如果没有此参数重新启动,则会禁用
firewall-cmd---zone=public---add-port=80/TCP---permanent
firewall-cmd---zone=public---add-port=1000-2000/TCP---permanent
重新加载:
firewall-cmd --reload
确认端口号是否打开:
firewall-cmd---zone=public---query-port=80/TCP
删除端口号:
firewall-cmd---zone=public---remove-port=80/TCP---permanent
二. iptables防火墙
也可以恢复传统的管理方法并使用iptables
系统停止文件d
系统掩码文件d
安装iptables-services
yum install iptables-services
电源接通启动的设定
系统启用选项
操作命令
系统停止iptables
系统开始iptables
系统重新开始iptables
系统读我
保存设置
服务可移植性保存
将端口添加到/etc/sysconfig/iptables
- arh-firewall-1-input-mstate-- statenew-mtcp-ptcp-- dport 8080-j accept
三.设置mysql
修改/etc/my.cnf文件
找到名为bind-address=127.0.0.1的行
变更为bind-address=0.0.0.0即可
2 .新用户远程连接到mysql数据库
grant allon.to admin @’%’identified by‘123456’withgrantoption;
flush privileges;
允许任何ip地址(%表示允许任何ip地址)的计算机使用管理员帐户和密码(123456 )访问此mysql server。
请注意,管理员帐户不一定需要存在。
root用户支持允许远程连接到mysql数据库
grantallprivilegeson.to“root”@“%”identified by“123456”withgrantoption;
flush privileges;