3

I 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 following command:

mysql -h xx.xx.xx.xx --port=3306 -u root -p

I get the following error:

ERROR 1042 (HY000): Can't get hostname for your address

I have tried putting the entry of client IP in server's %windir%\system32\drivers\etc\hosts file as:

<client-ip>  <client-hostname>
  • Server: MySQL 5.5
  • OS: Windows XP

3 Answers 3

5

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.

2
  • 1
    +1 The 2nd option worked..
    – M.N
    Aug 25, 2010 at 12:14
  • 1
    @Link down..............
    – Pacerier
    Jan 14, 2015 at 10:19
1

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.

1
  • Link down............
    – Pacerier
    Jan 14, 2015 at 10:19
-1

I had the same issue but on Windows 7. Disabling the Windows Firewall worked for me.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .