Languages
[Edit]
EN

HeidiSQL - connect to MySQL database via SSH Tunnel

8 points
Created by:
Emelia
517

In this article we would like to show how to connect to MySQL database using SSH Tunnel with HeidiSQL. This approach is recommended when we want to have secured connection with MySQL server or we don't have direct access to MySQL server and we need to connect to internal network to get access to MySQL server.

There ate two ways how to do it:

  • with PuTTY SSH tunnel option,
  • with HeidiSQL built-in SSH tunnel option.

This article presents second one option - easier option.

To better understand the way of getting connection look at simple visualisation:

HeidiSQL connection path to MySQL via SSH Tunnel
HeidiSQL connection path to MySQL via SSH Tunnel

As first we want to get connection with my-ssh-server.com using SSH. Created SSH connection creates special tunnel that let us to pretend like we are located directly on my-ssh-server.com. In our simple case MySQL server is located on the same machine with firewall and direct acces to it is not permitted. But we can use local IP address of MySQL server to get connection, because SSH tunnel forwarded us to internal local my-ssh-server.com network.

Note: port 3307 was used only to open SSH tunnel from My PC to my-ssh-server.com.

Read below steps to see how to configure, save and open that database connection.

Simple steps:

Edit
  1. create new session configuration,
    in below case, session name is: my_db_user_name@my-ssh-server.com - but we use any name,
  2. in Settings tab use following configuration:
    where:
    • SSH tunnel option is verry important,
    • 127.0.0.1 and 3306 indicate MySQL client connection configuration necessary to make connection from my-ssh-server.com internal network.
  3. in SSH tunnel tab use following configuration:
    where:
    • C:\Program Files\PuTTY\plink.exe is part of PuTTY software,
    • 3307 is any port used only to make connection from your computer to my-ssh-server.com, it can be changed to any unused port.
  4. save configuration,
  5. open connection.

Screenshots: 

Edit
MySQL client connection configuration - HeidiSQL
MySQL client connection configuration - HeidiSQL
MySQL client connection configuration via SSH tunnel - HeidiSQL
MySQL client connection configuration via SSH tunnel - HeidiSQL
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join