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

8/22/2022 - Mon
Gary

You can add
--skip-name-resolve

in your initial connection if you are unable to change it on the MySQL server side
Rob

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?
ASKER
mike99c

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
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER
mike99c

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.
Rob

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?
Rob

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.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
mike99c

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?
Rob

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

tagit, when you say I needto put an entry in the DNS for the IP, are you referring to an A record?
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Rob

It sure is. Are you sure you can connect to the server. Can you telnet or ping it?
ASKER
mike99c

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.
Rob

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
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Rob

So going back to my other post, can you telnet to that ip on that port from your server?
ASKER
mike99c

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
Rob

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Rob

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

Eg
telnet hostname 3306
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Rob

Ping is often blocked or rejected and uses a different port
ASKER
mike99c

Ok I don't want to go as far as installing the work bench but I will have a look at the firewall.
Rob

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.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
mike99c

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

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
Rob

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
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Rob

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
Rob

Specifically the reverse zones
Dave Baldwin

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.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
mike99c

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.
Dave Baldwin

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?
ASKER
mike99c

Yes it is all working now thanks.
Your help has saved me hundreds of hours of internet surfing.
fblack61