Last Updated: February 25, 2016
·
477
· tjuice

Connect to a remote MySQL DB without changing access grants (ssh required)

Many developers like to use phpmyadmin to administrate their database. But sometimes you wanna use our local SQL editor to fire up some statements or check / document the structure of a database via MySQL Workbench. The Problem is, that many servers are resticted to the local connection and maybe you will not change these restictions.
If you have ssh access than this is not a problem. You can tunnel easily the connection via ssh.

ssh -C -N user@remoteserver -L 3307:127.0.0.1:3306 

this call will tunnel the local port 3307 to the mysql port 3306 on the remote server.

You can now connect to your localhost with port 3307to get access to the remote MySQL Database with your local SQL Editor / Application.