MySQL connection command line can PHP unexpectedly can not

Source: Internet
Author: User
I use Mysql-h 192.168.7.14-uroot-proot-d sheep on the web host to connect to the remote database to see the data inside.
But the same server with PHP to connect unexpectedly failed.
 
  

Directly on the output "wrong while connect db!", the port can not be removed, not the constant directly written in the Mysql_connect parameter. I've shut down the firewall, and the web directory is the root owner and the group.
What else is there to be?


Reply to discussion (solution)

You change the die ("wrong while connect db!") to
Die (Mysql_error ())

No 3306 ports are specified.

You change the die ("wrong while connect db!") to
Die (Mysql_error ())
Output can ' t connect to MySQL server on ' 192.168.7.14 ' (13)

No 3306 ports are specified. Not specifying a port.

Pay the program with the server on the same server to use localhost directly

Echo Phpinfo (); see if the MySQL extension is normal.

Echo Phpinfo (); see if the MySQL extension is normal. It's a lot of output, almost normal.

Execute Setenforce 0, you can do it.

http://yemaosheng.com/?p=191
But I don't understand why, let's do it.


You change the die ("wrong while connect db!") to
Die (Mysql_error ())
Output can ' t connect to MySQL server on ' 192.168.7.14 ' (13)
The firewall intercepts requests that are accessed from outside.
Turn off the firewall.

  • 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.