Take the 2-minute tour ×

I've got a linux (ubuntu) computer at work from where I can connect to an external mysql server (not on company NAT). I've also got a laptop from which I want to connect to the mysql server but outside the work network.

How can I setup iptables or ssh port forwarding on my workstation so that it forwards connections to it (from my laptop at home) to the external mysql server?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

If you can ssh into your work computer do this on your home computer:

ssh -L 3306:mysqlserver:3306 user@workcomputer

and to connect to mysql, run this on your home computer:

mysql -h localhost

This forwards your local port 3306 off to the mysql server that your work computer can connect to.

share|improve this answer
I removed the comment where I said that this was not what I wanted because it was exactly what I wanted I just didn't understand it. Works great, thanks! –  Marlun Apr 8 '11 at 12:47
add comment

Your Answer


