Connect to MySQL over SSH

If you are running MySQL in a VM or on a remote host that runs sshd, you can connect to MySQL using the MySQL Workbench by creating an SSH tunnel. Assuming your remote MySQL is listening to localhost on port 3306, create an SSH tunnel like so:

ssh user@host -L 3307:127.0.0.1:3306 -N

 

enter your password at the prompt. Next, connect to MySQL at localhost on port 3307, the port forward will send the traffic to the remote server.