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

Source: Internet
Author: User
Tags mysql client

[Comment 1]
The former colleague penguin said that he installed MySQL 5.5 and reported the error 1042-can't get hostname for your address when using the mysql client for remote connection, however, the permission has been granted and the grant is successful.
This error indicates that "your address cannot obtain the host name ".Skip-name-resolveParameters.

Official documentation:

  • --skip-name-resolve

    Use IP addresses rather than host names when creating grant table entries. This option can be useful if your DNS does not work.

     

  • --skip-name-resolve

    Do not resolve host names when checking client connections. Use Only IP numbers. If you use this option, all
    HostColumn 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 variable
    Mysql>
    Failed. It seems that only my. CNF has been modified.

     

    Modify under the [mysqld] Node

    Skip-name-resolve
    # Ignore host name access
    Lower_case_table_names = 1
    # Ignore case sensitivity of database tables

    Restart mysqld process.

     

    [Comment 2]
    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 *. *
    '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 documents:

  • hostname

    Variable name hostname
    Variable Scope Global
    Dynamic variable No
      Permitted values
    Type string

    The server sets this variable to the server host name at startup.

     

    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 the database 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.