I just set up an SSH tunnel to a MySQL database using MyODBC version 3.51. It took several hours to get everything working; hopefully these instructions will save someone else the time I spent on it.
ssh -N -f -L 3307:localhost:3306 myname@myhostin Cygwin. The -N means "no command"; the tunnel will be set up, but nothing will be done. The -f means "run in the background", so the command will return to let me do other things.
The "-L 3307:localhost:3306" describes the kind of tunnel I want. It says the local port number is 3307. The remote machine should connect to itself ("localhost") on port 3306.
Finally, "myname@myhost" is the name of my account on the remote host for ssh to connect to.
This is all made quite convenient because I use public key logins with ssh-agent; you can read about setting those up somewhere else, e.g. here.
You could also use plink to make this connection.
Then, in Windows XP, go to Settings|Control Panel|Administrative tools|Data sources|Add... Choose the "MySQL ODBC 3.51 driver" (or whatever version you downloaded), and fill in the fields. The meaning is:
On the 2nd page of the dialog, choose to connect to port 3307 (matching the local port that the tunnel is using).
Then click "Test". Getting the details above right caused me the most grief. I got errors like
[MySQL][ODBC 3.51 Driver]#HY000Host 'localhost.localdomain' is not allowed to connect to this MySQL serverThis was fixed by granting my username access rights from host localhost.localdomain.
[MySQL][ODBC 3.51 Driver]Access denied for user 'mysqlname'@'localhost.localdomain' (using password: YES)This was fixed by switching to an 8 character password.
Last modified 23 May 2006