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.
MySQL ServerWindows Server 2008

Avatar of undefined
Last Comment
mike99c
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
Avatar of Rob
Rob
Flag of Australia image

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
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.
Avatar of Rob
Rob
Flag of Australia image

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?
Avatar of Rob
Rob
Flag of Australia image

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
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?
Avatar of Rob
Rob
Flag of Australia image

Do you have access to the remote server to be able to make these changes?
Avatar of mike99c
mike99c

ASKER

tagit, when you say I needto put an entry in the DNS for the IP, are you referring to an A record?
Avatar of Rob
Rob
Flag of Australia image

It sure is. Are you sure you can connect to the server. Can you telnet or ping it?
Avatar of mike99c
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.
Avatar of Rob
Rob
Flag of Australia image

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
Avatar of Rob
Rob
Flag of Australia image

So going back to my other post, can you telnet to that ip on that port from your server?
Avatar of mike99c
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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Rob
Rob
Flag of Australia image

That's not surprising the ping fails but you should try telnet on the mysql port 3306

Eg
telnet hostname 3306
Avatar of Rob
Rob
Flag of Australia image

Ping is often blocked or rejected and uses a different port
Avatar of mike99c
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.
Avatar of Rob
Rob
Flag of Australia image

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
mike99c

ASKER

tagit, do you know any way to apply skip-name-resolve to the connection string or something similar?
Avatar of Rob
Rob
Flag of Australia image

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
Avatar of Rob
Rob
Flag of Australia image

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
Avatar of Rob
Rob
Flag of Australia image

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
Avatar of Rob
Rob
Flag of Australia image

Specifically the reverse zones
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

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
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.
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

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
mike99c

ASKER

Yes it is all working now thanks.
Windows Server 2008
Windows Server 2008

Windows Server 2008 and Windows Server 2008 R2, based on the Microsoft Vista codebase, is the last 32-bit server operating system released by Microsoft. It has a number of versions, including including Foundation, Standard, Enterprise, Datacenter, Web, HPC Server, Itanium and Storage; new features included server core installation and Hyper-V.

86K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo