Sathish D Sathish D - 8 months ago 23
MySQL Question

How to connect MySQL database through two SSH hosts

How do I connect to MySQL database through two SSH hosts ?

Here is my situation: I have two SSH hosts as show below. MySQL is running in BOX2 host.

MyBox(MySQL GUI client) -----SSH(port 22)--->BOX1(IP: 190.xx.xx.xx)---SSH(port 22)--->BOX2(IP: 190.xx.xx.xx)[MySQL server]

My question is how do I connect if I have multiple SSH hosts to tunnel as shown above ?


I think this will help. Try this command from MyBox (having the MySQL Client)

ssh user@box1 -L some-local-port:box2:22

Now from the Client try to connect to connect this way

MySQL host : localhost
MySQL usernmae : mysql-username-of-server-installed-at-Box2
MySQL password : mysql-password-of-server-installed-at-Box2
MySQL port : 3306 (suppose mysql server at Box-2 is listening at port 3306)

In tunnelling info

SSH host : localhost
SSH pass : ssh-password-of-Box2
SSH port : some-local-port