Differences between the host name localhost and when connecting to MYSQL _ MySQL

Source: Internet
Author: User
What is the difference between the host name localhost and when connecting to MYSQL? bitsCN.com

If you carefully check the MYSQL permission table, you will find that there are records with the host name localhost and the host name When will these two records be used?

When you use/usr/local/mysql/bin/mysql-u root-p to access the MYSQL server, if the-h parameter is used, mysql will connect to the server through TCP/IP. without the-h parameter, the UNIX socket method will be used by default.

If the connection comes in through TCP/IP, the MYSQL server receives as the source host, and the UNIX socket method, the MYSQL server receives localhost as the source host.

If the MYSQL server enables skip_name_resolve, the MYSQL server will not convert the received IP address to a domain name, so the current_user of the former is root @ '127. 0.0.1 '. the current_user of the latter is root @ 'localhost '.

If skip_name_resovle is OFF according to the default MYSQL configuration, the MYSQL server will convert to localhost, and the current_user connected to the former and later will be root @ 'localhost'


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.