Learn PHP in the. Learn PHP Connection database today, the code is as follows:
<?php $link = mysql_connect ("127.0.0.1", "root", "123456"); if ($link) {echo ' data source connected successfully '; } else {echo "database connection failed, please check the account password". Mysql_error (). Mysql_errno (); }?>
Local tests are normally accessible
php/var/www/html/conndb.php
Windows machine using IE can not access, error is as follows:
Can ' t connect to MySQL server on ' 127.0.0.1 ' (13) 2003
Problem point: Firewalls and SELinux
Interim workaround:
Service Iptables Stop #停止iptables
Setenforce 1 #临时关闭Selinux
Permanent method
Chkconfig--leve 12345 iptables off
Vim/etc/selinux/config
Line 7th: selinux= enforcing
Modified: selinux= Disabled
Restart machine: Reboot
[Email protected] ~]# sestatus-v
SELinux status:disabled
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/78/32/wKiom1Z3pKiSshQAAACVY3kLUjI675.jpg "title=" Mysql.jpg "alt=" Wkiom1z3pkisshqaaacvy3kluji675.jpg "/>
This article is from the "Fly high into the Sky" blog, please be sure to keep this source http://xjlsky.blog.51cto.com/22754/1726811
PHP Connection Database error: Can ' t connect to MySQL server on ' 127.0.0.1 ' (13) 2003