Ubuntu: MySQL SSH Tunnel via the Terminal CodeUnit 04 FEB 2011

If you have a closed machine that doesn’t allow MySQL connections from the outside world but does allow SSH access in to the box, say hello to the world of SSH tunneling.

The concept is simple. Bind one of your local machine’s port via a SSH connection to another box on the outside. For example:

ssh -N -L 3307:127.0.0.1:3306 userName@remoteHost &

The above is simply linking the remote machine’s MySQL server on port 3306 to your local machine’s port 3307. In other words, you can now connect to the MySQL server on the remote machine by connecting to localhost:3307.

Nifty.

Related Posts:

About Craig Lotter

Software developer, husband and dad to two little girls. Writer behind An Exploring South African. I don't have time for myself any more.