SshPortForward
see also
SshLocalPortForward
SshRemotePortForward
example howto make a remote mysql server appear on localhost port 3306
create mysql tunnel
by binding local 3306 port to remote 'localhost' mysql 3306 port$ ssh -L3306:localhost:3306 myremoteusername@remote.server
run mysql command or gui
then you can use mysql locally to connect to the remote mysql server over ssh$ mysql -h 127.0.0.1 -u myuser -p
NOTE : DO NOT use the hostname 'localhost' in your mysql command line or you will get
Could not connect to host 'localhost'. MySQL Error Nr. 2002 Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
since mysql tools treat the hostname 'localhost' as a 'magic' word to force mysql to connect via a local socket instead of a tcp port but the local socket will not exist if your mysql server is not local which it is not if it is remote !
so you must either use 127.0.0.1 or add an alias to /etc/hosts
$ cat /etc/hosts 127.0.0.1 mysshsql
REFERRERS
MySqlFaultFinding
ssh