Differences between localhost and 127.0.0.1

Source: Internet
Author: User
Tags ip number mysql manual

Introduction: This is a detailed page for differences between localhost and 127.0.0.1. It introduces the knowledge, skills, experience, and some PHP Source Code related to PhP.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 339602 'rolling = 'no'>

What is the difference between localhost and 127.0.0.1? I believe some people will say it is a local IP address. Some people once said that 127.0.0.1 is better than localhost, and it can reduce resolution once. It seems that there are still some people who are not clear about this entry question. In fact, there is a difference between the two.

No1:

Localhost is also called local. The correct explanation is: local server
127.0.0.1 in windows and other systems, the correct explanation is: local address (local server)

NO2:

Localhot (local) is transmitted without a Nic! This is important because it is not restricted by network firewalls and network adapters.

127.0.0.1 is transmitted through the NIC and depends on the NIC. It is subject to network firewall and nic restrictions.

General settingsProgramWhen the local service uses localhost, it is the best. localhost will not be resolved to an IP address, nor occupy Nic or network resources.

Sometimes you can use localhost, but you cannot use 127.0.0.1. This is the case. Assume that when localhost is accessed, the current user's permission on the local machine is granted by the system. When IP is used, the local machine accesses the local machine through the network, which may involve the permissions of network users.

His words:

1. Use TCP/IP to connect to MySQL-H 127.0.0.1,
MySQL Server considers the connection from 127.0.0.1 or "localhost. localdomain"

2. When mysql-H localhost is used, UNIX socket is used instead of TCP/IP connection;
MySQL Server considers the client to be from "localhost"

3. "localhost" in MySQL permission management has specific meanings:
-MySQL manual 5.6.4... a host value may be a hostname or an IP number, or 'localhost' to indicate the local host.

Note: although there are differences between the two connection methods, when localhost is 127.0.0.1 by default, the permission records used by the two connection methods are the following 1. row record (because the record is first matched)

* *************************** 1. row ***************************

HOST: localhost

User: Root
......

* *************************** 2. row ***************************

HOST: 127.0.0.1

User: Root

Proof:

Shell> mysql-H 127.0.0.1
Mysql> status;

Current User:
Root@127.0.0.1

SSL:
Not in use
Current Pager:
Stdout
Using OUTFILE:
''
Using delimiter:
;
Server version:
5.1.33-log Source Distribution
Protocol version:
10
Connection: 127.0.0.1 via TCP/IP

Shell> mysql-H locahost
Mysql> status;

Current User:
Root @ localhost

SSL:
Not in use
Current Pager:
Stdout
Using OUTFILE:
''
Using delimiter:
;
Server version:
5.1.33-log Source Distribution
Protocol version:
10
Connection: localhost via UNIX socket

Shell> mysql-H xxxx (IP)

Mysql> status;

Current User:
Root @ IP

SSL:
Not in use
Current Pager:
Stdout
Using OUTFILE:
''
Using delimiter:
;
Server version:
5.1.33-log Source Distribution
Protocol version:
10
Connection: xxxx (IP) via TCP/IP

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/339602.html pageno: 7.

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.