Security in MySQL  /  Using Encrypted Connections  /  Connecting to MySQL Remotely from Windows with SSH

6.7 Connecting to MySQL Remotely from Windows with SSH

This section describes how to get an encrypted connection to a remote MySQL server with SSH. The information was provided by David Carlson .

  1. Install an SSH client on your Windows machine. For a comparison of SSH clients, see

  2. Start your Windows SSH client. Set Host_Name = yourmysqlserver_URL_or_IP. Set userid=your_userid to log in to your server. This userid value might not be the same as the user name of your MySQL account.

  3. Set up port forwarding. Either do a remote forward (Set local_port: 3306, remote_host: yourmysqlservername_or_ip, remote_port: 3306 ) or a local forward (Set port: 3306, host: localhost, remote port: 3306).

  4. Save everything, otherwise you will have to redo it the next time.

  5. Log in to your server with the SSH session you just created.

  6. On your Windows machine, start some ODBC application (such as Access).

  7. Create a new file in Windows and link to MySQL using the ODBC driver the same way you normally do, except type in localhost for the MySQL host server, not yourmysqlservername.

At this point, you should have an ODBC connection to MySQL, encrypted using SSH.

User Comments
  Posted by Joachim Baert on April 8, 2003
I frequently use the small and freeware PuTTY client with lots of options, and which has also a command-line version 'Plink', suitable for scripting.


  Posted by Manuel Razzari on September 4, 2003
Manage mysql via SSH from your windows machine with MySQLcc

You need:
And a hosting provider with SSH enabled!

Open putty.exe.

Specify the host name or IP of your site. Click on the "SSH" radio button.

Go to the settings Connection > SSH > Tunneling

Add new forwarded port:
Source port: 3306
Destination: localhost:3306
Click on the "Local" radio button.
Click "Add"

Go back to Session settings, type a name for Saved session and click "Save". Then click "Open"

You will be asked for login and password. Enter them.

On MySQLControlCenter, go to File > New, type a Name for your connection. Then at host name type
Then your user name and password in the following fields.

Click "Add", then double click on the new server icon to connect!
  Posted by on August 6, 2004
Manuel Razzari wrote good instructions to connect to the remote mysql server using putty server.

At my computer I have local instalation of mysql and mysqld uses the 3306 port so I have to choose different port for mysql connection:

My settings for example are:

Add new forwarded port:
Source port: 4000
Destination: localhost:3306
Click on the "Local" radio button.
Click "Add

When you conect to mysql client use localhost:4000 port.

Source port is arbitrarry port greater then 1024 only take in account that some application could use.

  Posted by Peter Laursen on April 25, 2006
There are several third-party MySQL clients that allow for SSH connections without ODBC or other sorts of exotic workarounds, most notably SQLyog Enterprise in my opinion.
Sign Up Login You must be logged in to post a comment.