Saturday 27 July 2013

MySQL Through SSH Tunnel

Below is my way of connecting to a remote MySQL server via an SSH tunnel. Fairly self explanatory but I can never quite remember the exact format for SSH tunnels.
ssh -f -L 3307:127.0.0.1:3306 <USER>@<HOST> sleep 20; mysql -h 127.0.0.1 -P 3307 -u<USER> -p <DB>

The sleep command gives it enough time to connect otherwise it would fail. Dirty, but I like it.

No comments:

Post a Comment