MySQL SSH Tunnel Howto
You would like to connect to your MySQL databases hosted on your HSR account but you can't do so directly because if we allowed that, it would open a security hole. Is there a workaround? Absolutely. Read on for the howto.
If your home/office/client computer is using Linux/Unix/BSD/OS X as its operating system then you can do the following:
Open up a Terminal/xterm session.
Edit your ~/.ssh/config file. You may have to create the directory ~/.ssh first, if you don't already have it, but you probably do. If ~/.ssh doesn't exist, be sure to chmod 700 it after you create it.
vi ~/.ssh/config
Enter the following into this file.
Host name_for_my_account
Hostname account_ip_address
User my_user_name
Localforward 3306 localhost:3306
The value for name_for_my_account is entirely at your discretion. You could, for example, set it to:
my-wonderful-hsr-account
You can get the value for account_ip_address by logging in to your account via SSH and typing:
dnsip `hostname`
my_user_name is your ssh username.
Now to open the forwarding connection, just run the following command in your local Terminal/xterm sessions:
ssh my-wonderful-hsr-account
This enables the forward and you get a normal SSH session as a bonus. :)
If you get the following error:
bind: Address already in use
... then log out and try changing Localforward 3306 localhost:3306 to the following:
Localforward 3307 localhost:3306
... and log in again.
This is useful if you like to use client-side SQL browsers such as CocoaMySQL, Navicat, etc.
Questions?
Please contact us with your questions and we will get back to you right away.
