Warning: mysql_connect(): Can't connect to MySQL server on 'xxx'
在命令行使用php执行可以正常访问数据库,但是使用url访问apache却报错无法访问。
问题比较迷惑人,看起来似乎跟mysql,php,apache有关,其实与Selinux有关。。。
getenforce
setenforce 0 可以解决(参考:http://serverfault.com/questions/503489/cant-connect-to-mysql-server-13-using-php-function)
或者使用:
setsebool httpd_can_network_connect=1
以后一定要多研究下selinux相关。。。