Ubuntu: MySQL SSH Tunnel via the Terminal

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.

You might also enjoy:

About Craig Lotter

Craig Lotter is an established web developer and application programmer, with strong creative urges (which keep bursting out at the most inopportune moments) and a seemingly insatiable need to love all things animated. Living in the beautiful coastal town of Gordon's Bay in South Africa, he games, develops, takes in animated fare, trains under the Funakoshi karate style and for the most part, simply enjoys life with his amazing wife and daughter. Oh, and he draws ever now and then too.
This entry was posted in Ubuntu and tagged , , , , . Bookmark the permalink.
    blog comments powered by Disqus