设置了远程数据库允许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
- 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
- mysql -h xx.xx.xx.xx --port=3306 -u root -p
- I get error as:
- ERROR 1042 (HY000): Can't get hostname for your address
- Have tried putting entry of client ip in server's etc\hosts file as
- <client-ip> <client-hostname>
XML/HTML代码
- 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.
- You have two options:
- 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.
- 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.
- 2.1) or put in my.ini :
- [mysqld]
- skip-name-resolve
- I'd recommend (1) if you can.
- Hope this helps.
然后也确实解决了这个问题。记录一下