Question

I have 2 machines: One has a mysql server that runs on localhost.The second one has no mysql server. I want to access the mysql server from the first machine on the second machine also on localhost. It should be something like a virtual localhost.

The first machine should log in the second machine via secure socket and should emulate the server there somehow. Is something like this possible, how is it called , and how does it work. Is this what is called a tunnel?

Was it helpful?

Solution

Yes, this is what is called a tunnel.

Assuming host A is running the mysql server and host B is the one that dose not.

To create the tunnel enter the following on host B:

ssh -L 3306:localhost:3306 username@A

(Add -f -N to the command to not execute any command on the remote host and immediately background the ssh connection).

This creates a listening port 3306 on host B which is forwarded over the ssh tunnel to localhost:3306 on host A.

Now just run mysql on host B and you should be able to connect to the mysql server on host A.

Hope it helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top