Bug #58529 MySQL can not connect to localhost
Submitted: 27 Nov 2010 0:47 Modified: 28 Dec 2010 8:04
Reporter: Jim Deuvall Email Updates:
Status: No Feedback Impact on me:
Category:MySQL Server: Errors Severity:S2 (Serious)
Version:3.5.1 OS:Microsoft Windows (XP, Vista and 7)
Assigned to: CPU Architecture:Any

[27 Nov 2010 0:47] Jim Deuvall
I have an app that uses an SSH tunnel to a remote MySL database on my ISPs server. 

The app when it starts, opens the tunnel, creates the ADO connection, queries the database to see if there are new entries and then lights a button on the form if the recordset count is greater than 0. 

If I reboot my computer and start the application, I get:

Run-time error -2147467259 (80004005) 
[MySL][ODBC 3.51 Driver] Can't connect to MySL server on 'localhost' (10061) 

and then closes the app. 

If I restart the app, without rebooting, it works beautifully and the button lights. I can then go in and add records without a problem.

Since it works on the second try after the error, I know that the drivers, passwords and ado connect string are all correct. 

If I reboot computer, it happens all again.  Have not found anything on this in forums. I've tried on various computers with different firewalls (windows, AVG, McAfee  and with the firewalls off and on) and makes no difference.

How to repeat:
If I reboot computers, the problem repeats.
[27 Nov 2010 10:01] Valeriy Kravchuk
This problem is not related to any bug in MySQL it seems. 

How that SSH tunnel is created? What software is used to make it?
[27 Nov 2010 13:30] Jim Deuvall
I open using Plink.  It is stated to be open before I execute the ado connection string.

I'm curious, how do you get to your conclusion that its not MySQL based on what is written?
[27 Nov 2010 14:14] Valeriy Kravchuk
I try to understand what changes after the error and before next successful attempt, or when computer restarts. Driver version does not change, MySQL server does not change (if you think it crashes, please, send error log that proves that). The most likely thing to change is status of your SSH tunnel. I can be wrong though.
[27 Nov 2010 15:22] Jim Deuvall
I've never used the log before.  How do I send to a log file?

DOes the plink ssh tunnel persist after turning off the app.  Is it a timng issue.  Not enough time to fulling create the tunnel?  It says its open.

Will the log assist in determining this.
[27 Nov 2010 15:44] Peter Laursen
@Jim .. if you start the PLINK process from inside you application you will of course also need to terminate it yourself. If you don't the process will still run and if you use it again on the same local port you will connect to the same remote server as you did first time.  This is actually a very dangerous scenario! DESTROY the PLINK instance when closing your application.  And if your application allows for multiple connections ensure that they will not use the same local port (because they will then connect to the same server!).

I think that you simply you do not initialize PLINK parameters properly first time you use it.

(not a MySQL person)
[27 Nov 2010 17:21] Jim Deuvall
I set the ado connection to nothing  and run the Close_SSH subroutine on the putty website.  But the ssh is still established when I close down the app.

I'm confused.
[28 Nov 2010 8:04] Valeriy Kravchuk
Error log of MySQL server (usually it is file named <hostname>.err in the data directory) can help to make sure that MySQL server has nothing to do with your problem. Or it can show information about server crash at the moment when you tried to access server. 

I doubt there was a server crash, though.
[29 Dec 2010 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".