Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to get to a mysql server on a remote network, and to get to it I currently have to do several ssh hops, so I can use the mysql command line interface. I'd really like to do a mulit-hop tunnel so I can just use a gui from my desktop. How would this work?

Here's the order:

MacDesktop --> DevServer -->StageServer --> Mysql01

All (except the mac desktop)are linux boxes, and mysql is running on the standard port. Any Hints? Or an exact connection string?

share|improve this question

migrated from Sep 20 '11 at 7:16

This question came from our site for professional and enthusiast programmers.

Hrm. Seems like that didn't work. Not sure what I'm doing wrong, but I'm essentially putting: (in Terminal one)>: ssh -L (in Terminal two (on my mac)) ssh -L 3306: It looks like the dev server is running mysql on it.. so am I going to need to forward a different port? If so, how? edit: I'tried port 3307, but when I did a netstat -an | grep 3307 on any of the hosts, it never showed up. :-/ – user95344 Sep 20 '11 at 19:03

1 Answer 1

You can use ssh to forward the ports(assuming that the mysql server is configured to accept connections from StageServer on port 3306):

# Forward port 3306 from Mysql01 to local port 3306 on DevServer using StageServer in the middle
DevServer > ssh -L 3306:Mysql01:3306 StageServer
# Forward the local port 3306 on DevServer to local port 3306 on your Mac
MacDesktop> ssh -L 3306: DevServer

Now configure the gui client to connect to (Make sure you're not running mysql on your Mac or forwarding to port 3306 will fail, or use another port for forwarding)

Edit: Make sure that local port forwarding is enabled in ssh server configuration.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.