MySQL uses host name (127.0.0.1) to connect

Source: Internet
Author: User
Tags mysql host

Recently encountered a problem, connect MySQL host name with localhost can, with 127.0.0.1 is not. So Google a few, summed up, to do memo it.

  I. MySQL-initiated configuration

The configuration file, the My.cnf file, is loaded first when MySQL starts. In this file we can set the IP limit of the connection database, as

    

  Two. mysql verifies the connection process.

We know that the MySQL server is controlled by user access through the permissions table, and the permissions table is placed in the MySQL database and initialized by the mysql_install_db script. These MySQL permission tables are user,db,table_priv,columns_priv and host, respectively. The structure and contents of these tables are described below:

User Permission Table    : Records the user account information that is allowed to connect to the server, which has a global level of permissions. DB Permission table: Records the operation permissions of each account on each database. Table_priv Permissions table: Records operation permissions at the data table level. Columns_priv Permissions table: Records the operation permissions at the data column level. Host Permission table: The database-level operation permissions on a given host are controlled more carefully with the DB permission table. This permission table is not affected by the grant and REVOKE statements. What is the access process for the connected database:1. First from the user table in the host, user, password 3 fields to determine whether the connection hostname, username, password exists in the table, the existence is authenticated;2. After the first step, the database, table, column and other permissions are queried and allocated. three. AnalysisThe 127.0.0.1 connection to the database may be the following three reasons: 1. The IP restrictions in the my.cnf file are generally reported as such errorssqlstate[hy000] [2002] Connection refused2. The hostname of USER Permission Table 127 does not exist, the general error is      sqlstate[hy000] [1130] Host ' xx.xx.xx.xx ' isn't allowed to connect to this MySQL server3. User name password filling error, the general mistake is ERROR 1045 (28000): Access denied for user ' root ' @ ' 127.0.0.1 ' (using Password:yes)      

  four. Miscellaneous1. Host name localhost is connected to the database through a UNIX socket, and the host name IP is connected via TCP/IP. Direct

MySQL uses host name (127.0.0.1) to connect

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.