MySQL 1042 Can't get hostname for your address Problem Analysis and Solution Process

Source: Internet
Author: User

MySQL 1042 Can't get hostname for your address Problem Analysis Solution Process [Comment 1] former colleague penguin said he installed mysql 5.5, found that when using the mysql client remote connection, the error 1042-Can't get hostname for your address is reported, but the permission has been granted and the grant is successful. This error indicates that "your address cannot obtain the host name", and I thought of the skip-name-resolve parameter. Official documentation: -- skip-name-resolveUse IP addresses rather than host names when creating grant table entries. this option can be useful if your DNS does not work. -- skip-name-resolveDo not resolve host names when checking client connections. use only IP numbers. if you use this option, all Host column values in the grant tables must be IP numbers or localhost. see Section 7.7.11, "How MySQL Uses DNS ".

mysql> show variables like '%skip_name_resolve%';+-------------------+-------+| Variable_name     | Value |+-------------------+-------+| skip_name_resolve | ON   |+-------------------+-------+1 row in set (0.00 sec)mysql> set global skip_name_resolve=0;ERROR 1238 (HY000): Variable 'skip_name_resolve' is a read only variablemysql> 

 

Failed. It seems that only my. cnf is modified under the [mysqld] node.
Skip-name-resolve # ignore the host name to access lower_case_table_names = 1 # ignore the case sensitivity of the database table name

 

Restart MySQLD process. [Comment 2] comments from former colleague Penguin:
mysql -h 192.168.1.101 -u root -p

 

My local mysql.192.168.1.101 is a local IP address. Grant all privileges on *. * to 'hive' @ '192. 168.1.101 'identified by 'hive' with grant option; this means that the connection fails and the permission is incorrect. How can this problem be solved. View official documentation: hostnameVariable Name hostnameVariable Scope GlobalDynamic Variable No Permitted ValuesType stringThe server sets this variable to the server host name at startup.
[html] mysql> show variables like '%hostname%';  +---------------+-------------------------------------------+  | Variable_name | Value                                     |  +---------------+-------------------------------------------+  | hostname      | xxxxx.china.online.xx.com |  +---------------+-------------------------------------------+  1 row in set (0.00 sec)    mysql> set global hostname='xxxxx2.china.online.xx.com';  ERROR 1238 (HY000): Variable 'hostname' is a read only variable  mysql>   

 

Failed. Only my. cnf is modified. Under the mysqld Option
[Mysqld] # comment out the parameter. mysql cannot access it directly using the local ip address # hostname

 

Restart the mysqld service.

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.