Port forward mysql on local network with SSH
From DevOps Notebook
Run from server you wanna access to MySQL that is on private network
that is not in same network as we are.
$ ssh -v -4 -N -L 3307:<sql_server_private_ip>:3306 root@<remote_host> $ mysql -h127.0.0.1 -p3307
If we wanna make connection persistent and auto reconnect:
$ autossh -M 0 -f -q -N -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" \ -L 3307:<sql_server_private_ip>:3306 root@<remote_host>