Replace MySQL remote connection with tunnel


The first time of this paper is to hit the water – replace MySQL remote connection with tunnel


Tunnel is an engineering building buried in the ground. It is a form of human using underground space. Tunnel can be divided into traffic tunnel, hydraulic tunnel, municipal tunnel and mine tunnel. –Source: Baidu Encyclopedia



Before debugging mysql, checking data and modifying data, the command line is not convenient. You always think of a remote account of Mysql to access the database. As time goes by, I have developed the habit of leaking out the 3306 port. I didn’t think of the security problem. Recently, under the guidance of the big guy, I came into contact with the way of the tunnel, and I think it’s very useful. Without disclosing the port number, I can view MySQL as freely as a remote connection, which is very useful. Now I share it.


First of all, there must be a tool like xshell, which can access the server through SSH and tunnel. This paper takes xshell as an example

Select session, right-click properties

After logging in to xshell, open the session window and select any session, right-click the property

Replace MySQL remote connection with tunnel

Selected tunnel

Replace MySQL remote connection with tunnel

Adding tunnels

Replace MySQL remote connection with tunnel

View – > tunnel pane

After entering the account number and password to log in to the server, click

Replace MySQL remote connection with tunnel

You can see that a box pops up at the bottom of the xshell, switches to the transfer rule, and you can see that the connection is successful

Replace MySQL remote connection with tunnel


When it comes to MySQL visualization tools, I have to mention Navicat. I think Navicat is the best MySQL visualization tool I have ever used.
To continue, first open the Navicat tool, create a new connection, and fill in the corresponding IP address and port in the xshell tunnel before filling in

Replace MySQL remote connection with tunnel

Note: the port of MySQL should be the same as the listening port when adding the tunnel, otherwise it cannot be connected.

MySQL connection user name and password fill in MySQL user name and password on the server, click OK, the connection is successful! Now you can operate the remote database just like the local database, which is very convenient.

Add: SSH login remote database

After the prompt of the community classmate @ Xu’s novel, you can also use the SSH function of Navicat to connect to the remote database. The specific operations are as follows:

SSH enter the account password of the server:

Replace MySQL remote connection with tunnel

Enter the MySQL account and password of the server in the general window

Replace MySQL remote connection with tunnel

It’s simpler than a tunnel.


The above is the sharing of this article.

Recommended Today

Configure Apache to support PHP in the Apache main configuration file httpd.conf Include custom profile in

In Apache’s main configuration file / conf/ http.conf Add at the bottom Include “D:workspace_phpapache-php.conf” The file path can be any In D: workspace_ Create under PHP file apache- php.conf file Its specific content is [html] view plain copy PHP-Module setup LoadFile “D:/xampp/php/php5ts.dll” LoadModule php5_module “D:/xampp/php/php5apache2_2.dll” <FilesMatch “.php$”> SetHandler application/x-httpd-php </FilesMatch> <FilesMatch “.phps$”> SetHandler application/x-httpd-php-source </FilesMatch> […]