Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to set up SSH tunneling on a remote web server to another MySQL server so that the database can be browsed easily with MySQL Query Browser. I'm following this page but cannot connect to the MySQL server.

What I've done:

  1. logged in to the web server with Putty via SSH.
  2. typed ssh -L 33060:[database]:3306 [myusername]@[webserver_address] where [...]s are altered by the actual information.
  3. I was asked a password and typed it and got the following message. So it seems login was successful.

    socket: Protocol not supported

    Last login: .... 2012 from .... Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994 The Regents of the University of California. All rights reserved.

    FreeBSD 7.1-RELEASE....

    Welcome to FreeBSD!

  4. Opened MySQL Query Browser in Windows and entered

Server Host: localhost Port: 33060 UserName: myusername PassWord: mypassword

And it says,

Could not connect to the specified instance.
MySQL Error Number 2003
Can't connect to MySQL Server on 'localhost' (10061)

Sorry if this is too basic. Thanks for your information.

share|improve this question
Why are you creating the tunnel on the web server? Shouldn't you be setting up the tunnel in putty? Doesn't your web server already have access? I am having problems following what you are trying to do here. Do you want to access the mysql server from your Windows client where you are running putty? Or what? – Zoredache Sep 25 '12 at 0:15
@Zoredache Do you want to access the mysql server from your Windows client where you are running putty? -- Yes, exactly. I'd like to browse the remote database with a nice GUI implemented software from my PC. I'm just following the instruction of the link I posted. If this could be set up all in Putty, I'd like to do it in Putty. That way I don't have to log in to phpMyAdmin via the web browser, which is somewhat slow and cumbersome compared to direct access with a such method. – Teno Sep 25 '12 at 8:54
up vote 2 down vote accepted

Since you want to access a remote system from your windows host which you are using Putty from, you need to be creating the tunnel within Putty, not on the remote system.

Setting up a tunnel in Putty is pretty straight forward.

  • Open putty
  • Load your save session if you have one, or enter any connection information.
  • Scroll down to the Connection -> SSH -> Tunnels
  • Set the source port to 33060
  • Set the destination to be the IP of the database server followed by :3306 for the mysql port. So something like
  • Click 'Add'
  • Click back over to the session tab, and choose save, or simply click open to start the connection

putty tunnel page

Once connected, fire up your database application and from the application try to connect to a server listening on

share|improve this answer
Wao, it worked! I could not find which option to choose from Local, Remote, or Dynamic and when I chose Local it went though. Thank you so much. – Teno Sep 25 '12 at 17:23

EDIT: Just saw that you're using a wrong connection string:

ssh -L 33060:[database]:3306 [myusername]@[webserver_address

Try with:

ssh -4 -L 33060:localhost:3306 [myusername]@[webserver_address

The -4 option forces the use of IPv4 and the localhost is the destination for the bind port (in your case MUST be locahost)

Connect using localhost:33060 and remote credentials.

That should work!

Otherwise check your server ssh daemon configuration for this:

AllowTcpForwarding yes

Otherwise connect to your server with the ssh -vv user@host option ,this will bring you some more info, if you see that the bind port failed at least you should see the reason.

share|improve this answer
Doesn't seem to work. I get the same message when trying to connect with MySQL Query Browser. I must be doing something wrong. AllowTcpForwarding yes gives "AllowTcpForwarding command not found" ssh -vv user@host gives a long list of debug lines. Should I post them? One thing I'd like to be clear is that the database server and the web server have different domains in my case. So I'm afraid that localhost in ssh -4 -L 33060:localhost:3306 [myusername]@[webserver_address] does not point to the database server. I'm not sure. – Teno Sep 25 '12 at 9:03
I also tried ssh -4 -L 33060:[web_server_address]:3306 [myusername]@[database_server_address] but this gives a timeout message. – Teno Sep 25 '12 at 9:11
Is your PC running windows? – Martino Dino Sep 25 '12 at 12:33
Yes. I used Putty to log in the web server and typed those commands in Putty. – Teno Sep 25 '12 at 12:44
NONOONOONONONO! Don't use this on th server, instead go in putty options, connections->ssh->options and set the correct option in port forwarding. check – Martino Dino Sep 25 '12 at 19:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .