Link to home
Start Free TrialLog in
Avatar of mike99c
mike99c

asked on

"Can't get hostname for your address" error when remotely connecting to MySQL database from Windows server

I have a test script written in ASP classic to connect to a remote MySQL database from a Windows 2008 server. I am using the ODBC driver  - MySQL ODBC 5.2 ANSI Driver.

Unfortunately I get the following error:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[MySQL][ODBC 5.2(a) Driver]Can't get hostname for your address

I have looked online and I understand one solution is to add skip-name-resolve to a my.ini MySQL installation file. However I don't have MySQL installed on the windows server as I don't actually need it. The driver should be enough.

I know the script works because I have tried it on another Windows 2008 server. I have tried opening port 3306 for both inbound and outbound using the Windows Firewall rules.

Any help would be appreciated.
Avatar of Gary
Gary
Flag of Ireland image

You can add
--skip-name-resolve

in your initial connection if you are unable to change it on the MySQL server side
Failing that, add an alias record to your DNS on your 2008 server.
Why not change the ODBC to the ip address rather than the hostname?
Avatar of mike99c
mike99c

ASKER

GaryC123, can you please explain how I can add skip-name-resolve into the connection string? This is what I currently use (Values changed for security) :

DRIVER={MySQL ODBC 5.2 ANSI Driver}; SERVER=111.11.111.111; PORT=3306; DATABASE=dbasename; UID=root; PASSWORD=dbpassword; OPTION=3
Avatar of mike99c

ASKER

tagit, from my previous post I have given the connection string I use and as you can see it does use an IP address. This means it is trying to resolve the hostname from it which I am trying to avoid.
Sure I understand now.  However, could you still put a reverse entry in your DNS for that IP?  And what about specifying the hostname instead of the IP?
Also in your question:

I have looked online and I understand one solution is to add skip-name-resolve to a my.ini MySQL installation file. However I don't have MySQL installed on the windows server as I don't actually need it. The driver should be enough.

You add skip-name-resolve to the my.ini file on the server running MySQL! not from where you are connecting from.
Avatar of mike99c

ASKER

tagit, I tried adding the hostname in place of the IP address and I get a can't connect error. Is the syntax different when you apply the host name?
Do you have access to the remote server to be able to make these changes?
Avatar of mike99c

ASKER

tagit, when you say I needto put an entry in the DNS for the IP, are you referring to an A record?
It sure is. Are you sure you can connect to the server. Can you telnet or ping it?
Avatar of mike99c

ASKER

tagit, I do not have access to the remote server so this fix needs to be made my end. I know the connection works as I tried it on another server.
At this stage forget about the DNS entries until we're confident about the connection as it looks like you can't even connect to the server
So going back to my other post, can you telnet to that ip on that port from your server?
Avatar of mike99c

ASKER

Ok this is interesting. On the server where I cannot connect to the database I tried to do a ping and I get a time out with a 100% eventual loss.

I decided to try this on the server where I can get a connection and the ping actually failed with the same timeout and 100% loss.

I was also getting the same timeouts using tracert.
ASKER CERTIFIED SOLUTION
Avatar of Rob
Rob
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That's not surprising the ping fails but you should try telnet on the mysql port 3306

Eg
telnet hostname 3306
Ping is often blocked or rejected and uses a different port
Avatar of mike99c

ASKER

Ok I don't want to go as far as installing the work bench but I will have a look at the firewall.
What port are you referring to? If it's ping then forget it as is probably the remote server rejecting the ping not your server given the server that does work times out as well.
Avatar of mike99c

ASKER

tagit, do you know any way to apply skip-name-resolve to the connection string or something similar?
You said you'd opened port 3306 inbound and out on the firewall but is the server running an anti virus solution? That quite often blocks these types of connections too so worth checking that those settings correspond with the server that does work
Skip-name-resolve is a server command and nothing to do with the client configuration
http://dev.mysql.com/doc/refman/5.5/en/server-options.html#option_mysqld_skip-name-resolve
The remote server is trying to resolve your server's host name from the ip address and can't but it can with your other server.
Check the dns entries on the server that workswith the server that doesn't
Specifically the reverse zones
In more general terms, can you make ANY connection to that server?  HTTP?  FTP?  You could have been given the wrong address or the remote firewall may not be set up to allow you access.  If that is the case, there is nothing you can do on the client to fix that.
Avatar of mike99c

ASKER

Ok in the end the server hosting company had to adjust their firewall to allow that port to be used despite me having opened it in Windows Firewall.
Each computer has it's own firewall and both have to be open to the port to communicate between them.  So it's working now?
Avatar of mike99c

ASKER

Yes it is all working now thanks.