Plurrrr

Mon 29 Apr 2019

Create an SSH Tunnel for MySQL Remote Access

To create a SSH tunnel that listens on port 3307 on localhost and connects to port 3306 (MySQL) on example.com use:

ssh -fNL 3307:127.0.0.1:3306 \
    user@example.com

If successful you can login to MySQL running on the remote host by executing on localhost:

mysql -h 127.0.0.1 -P 3307 \
    -u USER -p DATABASE

This also works with applications like MySQL Workbench.