So if I was to set up an ssh tunnel for MySQL in terminal I would forward remote 3306 to local 3307:

ssh -L 3307: user@domain.com

mysql -h -P 3307 -u user -p db

When connecting in the same way using MySQL workbench there seems to be no option to specify the local port to forward to. So which one does it use? I'd like to be able to connect via tunnel to a remote database using MySQL workbench, and to also connect to it in the terminal via the workbench ssh connection, for which I'd need to know the local port workbench used.

Thinking it may use local 3306, I tried making a tunnelled connection in workbench and then the following in terminal, but it did not work:

mysql -h -P 3306 -u user -p db
  • When you say "didn't work" what message did you receive/ behaviour did you observe? – Michael Green Jun 29 '14 at 12:00
  • @MichaelGreen I got an unknown database error. Ie. I assume mysql was just trying to connect locally where the relevant database does not exist. If I do have the same database and user locally it will just connect to this one. – Collierre Jun 29 '14 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.