3

I have a very strange problem with SSH Tunnel. I want to connect to a remote MySQL Server using an SSH Tunnel. I have created the tunnel with great success in the past, but for a strange reason it's not OK now. The Tunnel is created as: ssh [email protected] -T -N -L 6603:localhost:3306.

When I try to connect to the remote MySQL Server, the connection is performed on the local MySQL server!

So, I tried to use the ssh [email protected] -T -N -L 6603:remote.com:3306 which is not what all how-tos say, but what the man page do.

No success :( Everything that I have tried is not working and now I am really confused. What is wrong with that setup?

1
  • How are you connecting to mysql? Commented Feb 20, 2012 at 7:45

2 Answers 2

2

Are you connecting to the server with the -P command line option? Like:

 mysql -P 6603 -u user -p 
3
  • Of course. And to be sure that I don't use the local socket, I use the --protocol tcp option too. Commented Feb 20, 2012 at 8:29
  • 2
    OK, I found it. The problem is that I used the "localhost" which by default it connects to your mysql server though the UNIX socket. So, I should use 127.0.0.1 as I did in the past. Archive logs saved my day. Commented Feb 20, 2012 at 9:11
  • Peter, thanks for posting your solution. I was just preparing to ask the same question here, and voila! I tried your suggestion and it worked like a charm. Now if I could just get back the lost hour I wasted, trying to solve it myself... Commented May 8, 2015 at 4:06
0

try: ssh -L6603:localhost:3306 ssh [email protected]

aka, forward all traffic to localhost port 6603 to remove.com port 3306

You would then use host: 'localhost' and port 6603 to connect to server.

You can also check to make sure that the local port is not in use (netstat -tnlp for example) and that 3306 is not being blocked by a firewall.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.