MySQL Database and PHP program in the same server,php connection database how to write?

Source: Internet
Author: User
Keywords Php
MySQL Database and PHP program installed on the same server, PHP connection to the database, db_host write localhost, or this server's IP?

Reply content:

MySQL Database and PHP program installed on the same server, PHP connection to the database, db_host write localhost, or this server's IP?

The same server is completely unnecessary to write dead machine IP, the machine's IP will change.
Write localhost, or 127.0.0.1.

IP address write 127.0.0.1 or localhost is OK, the other unchanged ...

As long as you do not write the public network IP, LAN IP may also go through the network card and routing, recommended 127.0.0.1 or locahost .

Landlord refers to the server is the cloud host or virtual host, the cloud host, according to the answer is basically no problem, if it is a virtual host, the database link needs to provide the database address, user name, password and database name

127.0.0.1 local Use this on the line.

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