[Solved] SQLSTATE[HY000] [2003] Can’t connect to MySQL serv

 

I’ve really seen what SELinux can do, and I’ve been looking for a long time for the cause of this problem:

It turns out that SELinux doesn’t allow httpd access to the extranet, and yesterday I installed Chrome and it didn’t allow me to run ….. under the root account

SQLSTATE[HY000] [2003] Can’t connect to MySQL server on ‘XXX’ (13)

Solution:

Selinux’s setting Can’t connect to MySQL (13)

Connecting to local database via mysql_connect(‘localhost’,’usr’,’pass’) in php is successful
However, mysql_connect(‘127.0.0.1:3306′,’usr’,’pass’) gives
can’t connect to MySQL server using ” (13) error
Cause.
#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
Solution:

#setsebool httpd_can_network_connect 1

————————————————————————————————————————

Linux Error: Can’t connect to MySQL server on ” (10060)

The above error occurred in the remote connection server, after solving the summary, if there are incorrect, please correct me.
There are three main reasons.
1, mysql authorization table does not have the remote machine privileges, and the need to add in the authorization table mysql.user
grant all privileges on *. * to ‘root’@’remote login IP’ identified by ‘remote login password’
flush privileges;

2, the network does not work, this will not be said.
3, firewall to prohibit port 3306, iptable for example
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 settings
1) Take effect after reboot
Enabled: chkconfig iptables on
off: chkconfig iptables off
2) Effective immediately, expire after reboot
Enable: service iptables start
Shutdown: service iptables stop

Similar Posts: