2

I need to do an ssh tunnel to connect to a mysql server. if i do :

me@local> mysql -h host -u user -p pwd

I get a 100 error

I have an ssh account on a distant server and this command works :

me@ssh-server> mysql -h host -u user -p pwd

I would like to create a ssh tunnel but i cannot figure out the propper command. Anybody got an idea ?

3

Use the -L parameter for SSH to create a tunnel and redirect port 3306 (MySQL's port).

ssh -f me@ssh-server -L 3306:ssh-server:3306 -N

Then simply connect locally as you would on ssh-server. If you're on Windows locally, the parameters are pretty much the same for plink.

  • If MySQL is running on the ssh machine, change "ssh-server" to "localhost" if it fails to connect. If MySQL is running on another host, use that other host's name in place of "ssh-server" in the -L option on the ssh command. Then when connecting to the MySQL server from the local machine, use "-h localhost". on the mysql command. – Skaperen Nov 9 '12 at 1:51
0

You better read more for port forwarding and SSH. read this http://www.debianadmin.com/howto-use-ssh-local-and-remote-port-forwarding.html or eventually a topic that I made recently might be useful for you https://stackoverflow.com/questions/3969264/noob-questions-for-svn-checkout-and-network-issues-regading-it. If you have further question reply to my answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.