[Comment 1]
 前同事企鹅上面说他安装的mysql 5.5,发现用mysql客户端远程连接的时候,报1042-Can’t get hostname for your address错误,但是权限已经grant了并且grant成功了。
 这个报错的意思是“您的地址无法获得主机名”,我就想到了skip-name-resolve参数。

官方文档:

  • --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 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 variable
    mysql>
    失败了,看来是只有修改my.cnf了

    在[mysqld]节点下修改

    skip-name-resolve
    #忽略主机名的方式访问
    lower_case_table_names=1
    #忽略数据库表名大小写

    重启MySQLD process即可。

    [Comment 2]
    前同事企鹅留言:
    mysql -h 192.168.1.101 -u root -p
    访问不了,我本地的mysql.192.168.1.101是本地ip地址。
    grant all privileges on *.* to 'hive'@'192.168.1.101' identified by 'hive' with grant option;就是报连接不上,权限问题,怎么搞定。

    查看官方文档:

  • 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>

    失败了,只有修改my.cnf了,在mysqld选项下面

    [mysqld]
    # 注释掉参数即可,mysql直接用本机ip不能访问
    # hostname

    然后重启mysqld 服务即可。

最新文章

  1. Centos6.5安装mysql不能启动,应该安装mysql-server
  2. 用 Python、 RabbitMQ 和 Nameko 实现微服务
  3. tyvj4541 zhx 提高组P1
  4. div垂直居中的几种方法
  5. ccpcfinal总结
  6. SAS文档:简单的随机点名器
  7. Atitit.java eval功能的实现  Compiler API
  8. Java for LeetCode 023 Merge k Sorted Lists
  9. 在网页中编辑报表的报表设计器Stimulsoft Reports Designer.Web报表控件
  10. 一个用httpPost,get访问外网接口,参数json,返回json的示例
  11. 《Two Days DIV + CSS》读书笔记——CSS选择器
  12. java File的getLastModified在不同操作系统以下存在差异
  13. lua的前景??
  14. 随手小记(es6)
  15. mybatis学习一
  16. MySql中order by和union all同时使用
  17. Python之旅Day1 数据类型初识(数字|字符串|列表|数据运算) 编码 表达式(if...else|for|while)
  18. 设计模式之观察者模式(Observer)
  19. VS2015(Xamarin)开发安卓WebApp笔记
  20. 18. Spring Boot 、注册Servlet三大组件Servlet、Filter、Listener

热门文章

  1. Codeforces.809E.Surprise me!(莫比乌斯反演 虚树)
  2. [HDU6196]happy happy happy
  3. Sublime Text2 默认语言(windows/unix)设置,Sublime插件大全
  4. poj 3667 线段树
  5. Problem F: 铺地砖
  6. oracle复杂查询是sql
  7. 洛谷OJ U552 守墓人 线段树模板题
  8. Linux中文件/文本的中文乱码解决方法
  9. 多线程_java多线程环境下栈信息分析思路
  10. C++ Primer 学习笔记_34_STL实践与分析(8) --引言、pair类型、关联容器