I am trying to access a mysql server via an SSH tunnel. My understanding is that this should be supported natively in Mysql Workbench (5.2.35 on Ubuntu 10). The following works:

Open shell

ssh -f [email protected] -L 33187:server.domain.com:3306 -N

Open MySql Workbench

connect to localhost using port 33187 using connection method "Standard TCP/IP"

The following does not work:

kill any ssh port forwarding to start with a clean slate.

Open Mysql Workbench

Choose connection method "Standard TCP/IP over SSH"

Enter the following connection variables (which appear to align with previously working ssh command:

  • SSH Hostname: server.domain.com
  • SSH Username: jblow
  • SSH Password: password of jblow on server.domain.com
  • MySQL Hostname: localhost (or, tried it both ways)
  • MySQL Server Port: 33187

Ultimate goal is to provide a workbench configuration file which contains the proper setup (minus passwords) for many servers which users (devs) can simply place on their machines and be able to easily access appropriate DB's via existing connections listed in front page of mysql workbench. Worst case scenario I can give them a bash script to put in their .bashrc plus the workbench config file... but I'd prefer one file if I can, especially because I have users on Windows so if I can use a workbench config file, then it will be essentially the same procedure for windows users and for linux users.

NOTE: The goal is to have mysql workbench map from 3306 which is the port on the remote server to some other port locally (as happens in the example ssh command). putting 3306 as the MySQL Server Port causes an error because 3306 is not available on my local machine (because it is running a local mysql instance). After looking at this further, it appears this is not possible. If I kill the local mysql server instance (freeing port 3306) then mysql workbench can connect using 3306 as the mysql server port (which is the correct port on the remote machine), but there does not appear to be a way to support both a local mysql instance and a remote connection via ssh solely through mysql workbench as it gets port conflicts. Using port mapping requires either some iptables entries or doing the ssh tunneling separately from the mysql workbench configuration I think.

2 Answers 2


You're doing your ssh forwarding backwards, i.e. you're forwarding local port 3306 to 33187, use -R localhost:33187:server.domain.com:3306. For the workbench use MySQL Server Port 3306 and MySQL Hostname: localhost

What specifically is the error you're getting, I'm having a problem myself using a custom ssh port, i.e. SSH Hostname server.mydomain.com:13711 the workbench for whatever reason doesn't actually attempt a connection (verified by watching the logs)

MySQL Hostname: localhost (or, tried it both ways)
MySQL Server Port: 33187

Change it to:

MySQL Hostname: server.domain.com
MySQL Server Port: 3306

and try again.

  • That would fail (and did when attempted), since 3306 on my local machine is not an available port (since it has my local mysql server instance running on it). I will edit my question appropriately.
    – Robert
    Oct 31, 2011 at 18:58
  • updated my answer.
    – quanta
    Nov 1, 2011 at 0:41

You must log in to answer this question.

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