服务器的mysql需要对外访问,但为了安全起见,对外需使用33077端口。
通过防火墙firewalld来实现端口转发。
查询端口转发情况
firewall-cmd --query-masquerade firewall-cmd --add-masquerad --permanent firewall-cmd --reload注意事项:一定要加--permanent参数
转发33077端口到本机的3306端口
firewall-cmd --permanent --zone=public --add-forward-port=port=33077:proto=tcp:toport=3306注意,一定要加参数--permanent,否则不会生效。
外网链接远程服务器
mysql -h147.11.16.39 -uu_user -P33077 -p参考端口转发: https://www.cnblogs.com/ilvutm/p/9301919.html
