If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Connection to MySQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-03-12, 07:14
scottsanpedro scottsanpedro is offline
Registered User
 
Join Date: Jun 2003
Location: From UK, Brighton
Posts: 6
Red face Connection to MySQL

Hi all. I just want to figure out why I can't access a MySQL server from two different machines.
The MySQL Server is residing on a web server.
I have my home machine. Logs on 100%
I am then connecting to another business machine and trying to do exactly the same as am getting an error.
From ODBC : Coonection Failed [HY000][MYSQL][ODBC 5.1 Driver] Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (10065)
From an ADO.net connection I get : Test conenction failed becuase of an error in initializing provider. Unable to connect to any of the specified MySQL Hosts.

Could it be firewall? Presumably all is open for the way out. Is it getting block coming back in?

Thanks for any advice. Really stuck.
Scott
Reply With Quote
  #2 (permalink)  
Old 02-03-12, 13:37
it-iss.com it-iss.com is offline
Registered User
 
Join Date: Sep 2009
Location: San Sebastian, Spain
Posts: 620
Hi Scott,

network issues are always tricky. What I usually do in situations like this is
a) Check that we can connect to the MySQL server and that there are no firewalls blocking the connection request
b) Test using a separate application which uses the MySQL client
c) Test using a specific username and password
d) Test with my own connection string

Lets look at connectivity. The "telnet" utility is powerful as it allows you see if a connection can be established between a client machine and the server. If you run the following command:

telnet hostname_or_ip_address 3306

The 3306 is the default port on which the MySQL server is listening. I have created a mini screencast explaining the basics of client server here

If you do not get any error messages appearing then this means that a connection was established. The MySQL may return garbage but it is the connection that we are trying to establish here.

If you do not get a connection, this suggests that there is a firewall type issue on your PC or on your server.

I would suggest for the second part to download MySQL Workbench and install it on your client machine. Using the same hostname and port number establish a connection with the MySQL server specifying a username and a password.

If it is unable to establish a connection then have a look at the username and password that you are using and this is configured in the database.

Be aware that usernames and passwords are handled in a specific way in MySQL. It is possible to have multiple user accounts with the same name, different password depending on the host from which you are connecting. Make sure you have a username created in the database called name@hostname. If you want the user to be connected from any hostname then use the wildcard % i.e. name@%.

Finally if this works you need to have a look your applications configuration as it is most likely this is the source of the issue.

As for firewalls, these can exist at multiple locations, for example, on your Windows PC the firewall can block outgoing connections as well as incoming connections. You will need to determine which is the source of the problem. Also your web server database may have its own firewall which is blocking access or may even be limiting it to a specific source IP address. In other words if the IP address from which you are connecting is not configured in the firewall you may be blocked but someone else may have access.

Happy testing!!
__________________
Ronan Cashell
Senior Oracle/MySQL DBA
http://www.it-iss.com
Reply With Quote
  #3 (permalink)  
Old 02-05-12, 05:01
scottsanpedro scottsanpedro is offline
Registered User
 
Join Date: Jun 2003
Location: From UK, Brighton
Posts: 6
wow. thanks so much for the detailed response. It's great to get a definitive answer which I can follow up.
I have just run the telnet command and got
Connecting to xxx.xxx.xxx.xxx...Could not open connection on the host, on part 3306 : connect failed.
All hints towards a firewall problem.
I don't have control over the firewall so will pass on my findings to the administrator.
Cheers again
Scott
Reply With Quote
  #4 (permalink)  
Old 02-06-12, 03:36
it-iss.com it-iss.com is offline
Registered User
 
Join Date: Sep 2009
Location: San Sebastian, Spain
Posts: 620
If you are running from a Windows machine try disabling the firewall there first and retry the telnet just to make sure that the problem is not on windows. Remember to re-enable it afterwards.
__________________
Ronan Cashell
Senior Oracle/MySQL DBA
http://www.it-iss.com
Reply With Quote
  #5 (permalink)  
Old 02-06-12, 14:36
scottsanpedro scottsanpedro is offline
Registered User
 
Join Date: Jun 2003
Location: From UK, Brighton
Posts: 6
Yes. Once through the firewall all is well.
Many thanks again
Scott
Reply With Quote
Reply

Tags
mysql

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On