手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表2016年08月8日的文章

Error connecting remote MySQL server [ERROR 1042 (HY000): Can't get hostname for your address]

设置了远程数据库允许IP连接,也设置了bind ip为0.0.0.0 ,但有时候能连,有时候不能连接,而且还设置了是IP连接,报标题所在的错误,即 [ERROR 1042 (HY000): Can't get hostname for your address]。

开始就在想,是不是skip-name-resolve的问题,但因为我不是用host连接的,也不是内部的域名解析的问题。所以开始没注意,但google了之后,还是决定加了skipnameresolve

http://serverfault.com/questions/174242/error-connecting-remote-mysql-server-error-1042-hy000-cant-get-hostname-for
  1. ave MySQL 5.5 Server setup on a windows machine. I am able to connect to the server from console / app running on the same machine but not from a remote machine. While connecting using the command  
  2.   
  3. mysql -h xx.xx.xx.xx --port=3306 -u root -p  
  4. I get error as:  
  5.   
  6. ERROR 1042 (HY000): Can't get hostname for your address  
  7. Have tried putting entry of client ip in server's etc\hosts file as  
  8.   
  9. <client-ip>  <client-hostname>  
所有的回答都指向了skip-name-resolve
XML/HTML代码
  1. I believe this is to do with the fact that MySQL tries to establish the DNS name associated with your IP address on connect. See here for more information at the MySQL site.  
  2.   
  3. You have two options:  
  4.   
  5. 1) Fix the connecting machine's reverse DNS. Since you've already added the machine to the hosts file, this might be unnecessary. You should also issue a FLUSH HOSTS statement on the MySQL server. See the same link above for more information about this.  
  6.   
  7. 2) Run MySQL with the '--skip-name-resolve' option. However, if you do this, you won't be able to use DNS names in GRANT statements. Instead you'll be restricted to using IP addresses.  
  8.   
  9. 2.1) or put in my.ini :  
  10.   
  11. [mysqld]  
  12. skip-name-resolve  
  13. I'd recommend (1) if you can.  
  14.   
  15. Hope this helps.  
然后也确实解决了这个问题。记录一下
 
 

 
 

Tags: mysql