Mysqlworkbench use SSH tunnel to connect to MySQL database

Source: Internet
Author: User
Tags ssh

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.