LInux 开启防火墙网站无法访问,远程无法链接数据库
netstat -ntlp //查看当前所有tcp端口
端口都是开启的,数据库的localhost、@都配置了无法访问。
最后重新创建了端口网站就可以正常访问了,数据库也能远程链接
我的系统是 CentOS Linux release 7.4.1708
处理办法:
输入
firewall-cmd –zone=public –add-port=80/tcp –permanent
firewall-cmd –zone=public –add-port=3306/tcp –permanent
刷新
firewall-cmd –reload
然后进行访问,就可以了。
linux的一些操作命令
防火墙
启动:systemctl start firewalld
查看状态:systemctl status firewalld
停止: systemctl stop firewalld
禁用: systemctl disable firewalld
开启端口:
firewall-cmd –zone=public –add-port=81/tcp –permanent (–permanent永久生效,没有此参数重启后失效)
查看端口是否已开:firewall-cmd –query-port=80/tcp
开启端口: firewall-cmd –zone=public –add-port=80/tcp –permanent
刷新: firewall-cmd –reload
查看: firewall-cmd –zone= public –query-port=80/tcp tcp为自定义
删除: firewall-cmd –zone= public –remove-port=80/tcp –permanent
显示状态: firewall-cmd –state
———————
netstat -ntlp //查看当前所有tcp端口
netstat -ntulp |grep 80 //查看所有80端口使用情况
mysql添加用户
grant all privileges on xiaohongdian_test.* to ‘root’@’%’ identified by ‘root’ with grant option;
grant all privileges on xiaohongdian_test.* to ‘root’@’localhost’ identified by ‘root’ with grant option;