Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Have 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>
  • Server: MySQL ver 5.5
  • OS: Windows XP
share|improve this question

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer
1  
+1 The 2nd option worked.. –  M.N Aug 25 '10 at 12:14

This seems to be a reported bug in MySQL ver5.5. It was resolved using the following option in [server] section of my.ini file

skip-name-resolve

It disables the DNS lookup by MySQL for connecting peers.

The only thing to keep in mind is:

...in this case, you can use only IP numbers in the MySQL grant tables.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.