Thursday, May 15, 2008

Tunnel mysql through ssh

If you are looking to tunnel mysql through an ssh connection, use the following command on your desktop/client machine:

ssh -L 3307:localhost:3306 user@some.host.blah


Once established, you can connect to the remote mysql instance by connecting locally to port 3307.

This is useful when using a GUI application on a remote server where the MySQL port is closed off by firewall rules.

--Noel

1 Comments:

At 11:11 AM, Blogger /dev/noel said...

You can reverse an SSH tunnel by using the -R argument.

Example for reversing a MySQL SSH tunnel (from server back to desktop):

ssh -R 4005:127.0.0.1:3306 user@some.host.blah

 

Post a Comment

<< Home