PHP Connection Database error: Can ' t connect to MySQL server on ' 127.0.0.1 ' (13) 2003

Source: Internet
Author: User
Tags learn php iptables

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.