Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 user@remote.com -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 user@remote.com -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?

share|improve this question
How are you connecting to mysql? –  Roy Feb 20 '12 at 7:45

2 Answers 2

try: ssh -L6603:localhost:3306 ssh user@remote.com

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.

share|improve this answer

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

 mysql -P 6603 -u user -p
share|improve this answer
Of course. And to be sure that I don't use the local socket, I use the --protocol tcp option too. –  Peter Feb 20 '12 at 8:29
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 as I did in the past. Archive logs saved my day. –  Peter Feb 20 '12 at 9:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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