Now connected to an IDC MySQL server, due to network isolation, the need to ssh to a springboard to direct access to MySQL, and I want to use mysqlworkbench such as local clients directly connected to MySQL. The solution is to set up an SSH tunnel with the SSH command, and then Mysqlworkbench connect to the corresponding remote MySQL only by connecting to a local port.
Suppose the springboard is: 192.168.1.1 (it can be connected to MySQL)
MySQL IP is: 10.1.0.58 port is: 3306
The command to establish the SSH tunnel is as follows:
The code is as follows |
Copy Code |
# Establish SSH Tunnel Jay@jay-air:~ $ssh-F jay@192.168.1.1-l 2001:10.1.0.58:3306-n warning:permanently added ' 192.168.1.1 ' (RSA) to the list of known hosts. jay@192.168.1.1 ' s Password:
# Check the SSH process running in the background jay@jay-air:~ $ps-ef | grep ' Ssh-f ' | Grep-v grep 501 9729 1 0 6:10pm?? 0:00.19 ssh-f jay@192.168.1.1-l 2001:10.1.0.58:3306-n |
In the SSH command,-F indicates that SSH enters the background running state before executing the command (where no commands are configured to execute);-l specifies a local port (for example, 2001 here) that will be forwarded to a port on a remote IP (for example: 10.1.0.58:3306); Indicates that remote commands are not executed and are useful for scenarios where port forwarding is done only.
In Mysqlworkbench, the IP and port that was originally connected to MySQL are configured as a local SSH tunnel (set up here: localhost:2001)
In addition, the second in the Resources section tells how to set up an SSH tunnel in putty.
Http://www.revsys.com/writings/quicktips/ssh-tunnel.html
Http://davidngos.blogspot.com/2013/06/how-to-use-mysql-workbench-behind.html