
代码如下:
$server=127.0.0.1
println(Begin)
$link
=
mysql_connect($server,mysql,mysql)
if
(!$link)
{
die('Could
not
connect:
'
.
mysql_error().mysql_errno())
}
linux本机下使用php
mysql.php
可以查看运行结果,但是
在我的windows浏览器下报错:
代码如下:
Could
not
connect:
Can't
connect
to
MySQL
server
on
'127.0.0.1'
(13)
2003
原因:
代码如下:
#getsebool
-a
|
grep
httpd
[[emailprotected]
phpMyTest]$
getsebool
-a
|
grep
httpd
发现
httpd_can_network_connect
--
off
解决方案:
代码如下:
#setsebool
httpd_can_network_connect
1
原来是
SELINUX,所以我一般直接关闭SELINUX和
iptables
ip6tables
代码如下:
#
关闭SELINUX
chkconfig
--level
12345
iptables
off
service
iptables
stop
service
ip6tables
stop
查看SELinux状态:
1、/usr/sbin/sestatus
-v
##如果SELinux
status参数为enabled即为开启状态
SELinux
status:
enabled
2、getenforce
##也可以用这个命令检查
关闭SELinux:
1、临时关闭(不用重启机器):
setenforce
0
##设置SELinux
成为permissive模式
##setenforce
1
设置SELinux
成为enforcing模式
2、修改配置文件需要重启机器:
修改/etc/selinux/config
文件
将SELINUX=enforcing改为SELINUX=disabled
确定是否有权限通过别 ip访问你的mysql,可以用客户端通过ip或其他机器测试下。如果不可以访问需要你在mysql下执行下面的命令ip,密码根据自己的情况改下。
grant all privileges on *.* to root@'192.168.0.%' identified by 'yourpassword'
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)