centos7 centos中apache运行php需要连接mysql一直连不上,telnet访问mysql出错Connection closed by foreign host

时间:2023-03-09 14:27:54
centos7 centos中apache运行php需要连接mysql一直连不上,telnet访问mysql出错Connection closed by foreign host

执行命令:

getsebool -a|grep httpd

发现 
httpd_can_network_connect off

解决: 

setsebool httpd_can_network_connect  && setsebool httpd_can_network_connect_cobbler  && setsebool httpd_can_network_connect_db  && setsebool httpd_can_network_relay 

需要重新启动httpd

systemctl restart httpd.service