selinux 与 Can't connect to MySQL server
2015-10-21 18:12
519 查看
[code]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
来解决(参考自:http://stackoverflow.com/questions/4078205/php-cant-connect-to-mysql-with-error-13-but-command-line-can)
以后一定要多研究下selinux相关。。。
相关文章推荐
- linux下查看外网出口IP
- linux下查找端口号对应的服务名
- linux定时任务的设置
- 在fedora和centos之间进行rpm的spec文件转换
- 在Linux CentOS 6.6上安装Python 2.7.9
- Linux系统C语言读写文件总结 (一)
- linux驱动为自定义设备添加poll方法
- Linux 基于WEB开源的系统管理工具webmin
- linux服务器下验证码老是失败
- Linux中安装并配置SVN
- CentOS6.5中修改yum源
- Linux的automake出现的问题(Makefile.am: C objects in subdir but `AM_PROG_CC_C_O' not in `configure.ac')
- scp跨机远程拷贝
- linux(工具)
- java判断操作系统是windows还是linux
- 【转】CentOS 6 服务器安全配置指南
- centos MySQL 数据库安装
- 自己整理的常用Linux 命令
- centos7 mysql安装
- Centos 5 手动安装yum