SSH tunneled connection to a MySQL server

| | TrackBacks (0)

Nice write up on MySQL and SSH, practically anything that you can connect to can be tunneled over SSH.

Tunnelling MySQL Over SSH


To set up a tunneled connection to a MySQL server at remotehost.com, you can issue the following two commands on any client:

ssh -fNg -L 3307:127.0.0.1:3306 myuser@remotehost.com
mysql -h 127.0.0.1 -P 3307 -u dbuser -p db

The first command tells ssh to log in to remotehost.com as myuser, go into the background (-f) and not execute any remote command (-N), and set up port-forwarding (-L localport:localhost:remoteport ). In this case, we forward port 3307 on localhost to port 3306 on remotehost.com.

0 TrackBacks

Listed below are links to blogs that reference this entry: SSH tunneled connection to a MySQL server.

TrackBack URL for this entry: http://kennethhunt.com/mt/mt-tb.cgi/1875

About this Entry

This page contains a single entry by klsh published on February 18, 2008 8:49 AM.

Finding the inverse square root of a number with i = 0x5f3759df - (i>>1); was the previous entry in this blog.

andLinux vs cygwin an alternate *nix on windows uses linux kernel port is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.