"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.
mike99cAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GaryCommented:
You can add
--skip-name-resolve

in your initial connection if you are unable to change it on the MySQL server side
0
RobOwner (Aidellio)Commented:
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?
0
mike99cAuthor Commented:
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
0
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

mike99cAuthor Commented:
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.
0
RobOwner (Aidellio)Commented:
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?
0
RobOwner (Aidellio)Commented:
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.
0
mike99cAuthor Commented:
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?
0
RobOwner (Aidellio)Commented:
Do you have access to the remote server to be able to make these changes?
0
mike99cAuthor Commented:
tagit, when you say I needto put an entry in the DNS for the IP, are you referring to an A record?
0
RobOwner (Aidellio)Commented:
It sure is. Are you sure you can connect to the server. Can you telnet or ping it?
0
mike99cAuthor Commented:
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.
0
RobOwner (Aidellio)Commented:
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
0
RobOwner (Aidellio)Commented:
So going back to my other post, can you telnet to that ip on that port from your server?
0
mike99cAuthor Commented:
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.
0
RobOwner (Aidellio)Commented:
I know you've opened ports but it is looking like a local firewall problem. If you install mysql workbench on your laptop can you connect from the same location as your server?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RobOwner (Aidellio)Commented:
That's not surprising the ping fails but you should try telnet on the mysql port 3306

Eg
telnet hostname 3306
0
RobOwner (Aidellio)Commented:
Ping is often blocked or rejected and uses a different port
0
mike99cAuthor Commented:
Ok I don't want to go as far as installing the work bench but I will have a look at the firewall.
0
RobOwner (Aidellio)Commented:
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.
0
mike99cAuthor Commented:
tagit, do you know any way to apply skip-name-resolve to the connection string or something similar?
0
RobOwner (Aidellio)Commented:
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
0
RobOwner (Aidellio)Commented:
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
0
RobOwner (Aidellio)Commented:
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
0
RobOwner (Aidellio)Commented:
Specifically the reverse zones
0
Dave BaldwinFixer of ProblemsCommented:
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.
0
mike99cAuthor Commented:
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.
0
Dave BaldwinFixer of ProblemsCommented:
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?
0
mike99cAuthor Commented:
Yes it is all working now thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.