Use IP address to connect MySQL database in PHP

Source: Internet
Author: User
Tags bind connect mysql database

We usually use mysql_connect ("localhost", "usrname", "password") to connect to the MySQL database in the way we test them.

If we want to use the IP address of other host to connect the MySQL database, we need to modify the MySQL profile/etc/mysql/my.cnf, otherwise this error will appear:

Can t connect to MySQL server on 111

Skip-external-locking

#

# Instead of skip-networking The default is now to listen only

# localhost which are more compatible and are not less secure.

#bind-address = 127.0.0.1//This line is to be commented out

Once you have commented out this line of bind-address and then restart MySQL, you can use the IP address to connect to MySQL via other machines.

See more highlights of this column: http://www.bianceng.cn/webkf/PHP/

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.