You see this article from HTTP://WWW.CNBLOGS.COM/AYANMW
The PHP code is simple:
$server = "127.0.0.1";p rintln ("Begin"), $link = mysql_connect ($server, "MySQL", "MySQL"), if (! $link) {die (' Could Not connect: '. Mysql_error (). Mysql_errno ());}
Linux native use PHP mysql.php can view the results of the operation, but in my Windows browser error:
Could not Connect:can ' t connect to MySQL server on ' 127.0.0.1 ' (13) 2003
Reason:
#getsebool-A | grep httpd
[Email protected] phpmytest]$ Getsebool-a | grep httpd
Discover Httpd_can_network_connect-off
Solution:
#setsebool Httpd_can_network_connect 1
Turns out to be selinux, so I generally directly close SELinux and iptables ip6tables
# close Selinuxchkconfig--level 12345 iptables offchkconfig--level 12345 ip6tables offservice iptables stopservice ip6tables Stop View selinux Status: 1,/usr/sbin/sestatus-v # #如果SELinux The status parameter is enabled is on with SELinux status: enabled2, Getenforce # #也可以用这个命令检查关闭SELinux: 1, temporary shutdown (without restarting the machine): Setenforce 0 # #设置SELinux become permissive mode # #setenforce 1 setting SELinux to become enforcing mode 2, modifying the configuration file requires restarting the machine: Modify the/etc/selinux/config file to change selinux=enforcing to selinux=disabled
CentOS under httpd PHP connection MySQL native can, 127.0.0.1 cannot access