Using an SSH Tunnel
From OCS Support Wiki
Contents |
Important Notice
This guide has largely been replaced with our Connecting to MySQL via MySQL Workbench article, which explains how to use the new MySQL Workbench tool to connect easily via an SSH tunnel.
What is an SSH Tunnel
An SSH tunnel is a method of communicating securely with processes on the server that are not typically accessible from the Internet for security reasons. one of these services (and what is covered specifically in this article) is MySQL.
Since MySQL wasn't well designed for remote connections, we prevent outside connections to it via our firewall. However, there is an easy way to use an SSH tunnel to connect to our MySQL server via PuTTY. By bringing the MySQL port to your local machine, you can use tools like the MySQL Query Browser or Navicat.
Windows
Using PuTTY
If you don't have PuTTY installed, you can obtain it from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html. We recommend you download and install the Windows style installer.
Once PuTTY is installed, please confirm that you can successfully create an SSH connection to our servers with your account. You can learn more about this in Connecting_via_SSH.
Creating the Tunnel
Start PuTTY, and click on "Tunnels" in the side categories box as shown below.
Type 3306 in the Source Port text box, and put 127.0.0.1:3306, as pictured below, and return to the main screen by clicking on "Session" in the side categories box as shown below:
Establish your SSH connection as usual. Once made, you may use any MySQL administration tool by having it connect to 127.0.0.1 on port 3306.
Linux and Mac OS X
To create an SSH tunnel in Linux and on a Mac, use:
ssh you@yourdomain.com -L 3306:127.0.0.1:3306
Once you've logged in, you can now use any MySQL tool you want by just connecting to 127.0.0.1 on port 3306 on your local machine.


