SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'XXX' (13)
我可以真见识了 SELinux 的利害了, 这个问题让我找了好长时间的原因:
结果是 SELinux 不让 httpd 访问外网,昨天安装 Chrome 浏览器,结果不让 在根帐号下运行 .....
SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'XXX' (13)
解决方法:
Selinux 的设置 Can't connect to MySQL (13)
通过php的mysql_connect('localhost','usr','pass')连接本地数据库成功
但是,mysql_connect('127.0.0.1:3306','usr','pass')出现
can't connect to MySQL server using '' (13)的错误
原因:
#getsebool -a | grep httpd
[neo@neo phpMyTest]$ getsebool -a | grep httpd
allow_httpd_anon_write --> off
allow_httpd_mod_auth_ntlm_winbind --> off
allow_httpd_mod_auth_pam --> off
allow_httpd_sys_script_anon_write --> off
httpd_builtin_scripting --> on
httpd_can_check_spam --> off
httpd_can_network_connect --> off
httpd_can_network_connect_cobbler --> off
httpd_can_network_connect_db --> off
httpd_can_network_memcache --> off
httpd_can_network_relay --> off
httpd_can_sendmail --> off
httpd_dbus_avahi --> on
httpd_enable_cgi --> on
httpd_enable_ftp_server --> off
httpd_enable_homedirs --> off
httpd_execmem --> off
httpd_read_user_content --> off
httpd_setrlimit --> off
httpd_ssi_exec --> off
httpd_tmp_exec --> off
httpd_tty_comm --> on
httpd_unified --> off
httpd_use_cifs --> off
httpd_use_gpg --> off
httpd_use_nfs --> off
发现 httpd_can_network_connect --> off
解决方案:
#setsebool httpd_can_network_connect 1
---------------------------------------------------------------------------------------
Linux服务器下Can't connect to MySQL server on '' (10060) (转)
远程连接服务器出现以上错误,解决后做了下总结,如有不正之处,请指正。
主要有三个原因:
1、mysql授权表里没有远程机器的权限,及需要在授权表mysql.user添加
grant all privileges on *.* to 'root'@'远程登陆IP' identified by '远程登陆密码'
flush privileges;
2、网络不通,这个就不说了。
3、防火墙禁止3306端口,以iptable为例
vi /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3306-j ACCEPT
service iptables restart
ps: iptables设置
1) 重启后生效
开启: chkconfig iptables on
关闭: chkconfig iptables off
2) 即时生效,重启后失效
开启: service iptables start
关闭: service iptables stop
转载请注明(B5教程网)原文链接:http://www.bcty365.com/content-35-592-1.html转载请注明出处 原文链接:http://www.bcty365.com/content-35-592-1.html