Created
March 8, 2012 14:49
-
-
Save whylom/2001348 to your computer and use it in GitHub Desktop.
Open an SSH tunnel to a remote MySQL server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Open an SSH tunnel to port 3306 (default MySQL port) on a remote machine. | |
# Specify the local port with an optional 2nd argument. | |
# The default is 3307, in case you have MySQL running locally on 3306. | |
# | |
# $ tunnel user@host | |
# -> opens tunnel to host on port 3306, using local port 3307 | |
# | |
# $ tunnel user@host 3333 | |
# -> opens tunnel to host on port 3306, using local port 3333 | |
function tunnel { | |
port=${2-3307} | |
ssh $1 -L $port:localhost:3306 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment