Jerid Francom bio photo

Jerid Francom

Associate Professor of Spanish and Linguistics
Romance Languages
Wake Forest University

Curriculum vitae

Email Twitter Github Stackoverflow

This isn’t that hard to find out on the Internets, but I want to document a couple tips that I find useful once you create an SSH Tunnel to your remote MySQL database. After you create the tunnel, you will be able to interact with the database as if it were on your local machine, which simplifies running SQL scripts.

  1. Create an SSH Tunnel

    First open a command-line interface and enter:

    $ ssh user@host -L 3306:localhost:3306

  2. Connect to the remote database with with local(ish) syntax

    Then open another command-line window (without closing the other session) and enter:

    $ mysql -u db_user -h -p

The explicit for localhost seems to be important (I get a connection error when I just specify localhost).

And there you go, a local interface to your remote MySQL database. A more complete trick-laden version of this post can be found here