HeidiSQL - connect to MySQL database via SSH Tunnel

8 points
Created by:

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 using SSH. Created SSH connection creates special tunnel that let us to pretend like we are located directly on 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 network.

Note: port 3307 was used only to open SSH tunnel from My PC to

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

Simple steps:

  1. create new session configuration,
    in below case, session name is: - but we use any name,
  2. in Settings tab use following configuration:
    Network type:    MariaDB or MySQL (SSH tunnel)
    Hostname / IP:
    User:            my_db_user_name
    Password:        my_db_user_password
    Port:            3306
    • SSH tunnel option is verry important,
    • and¬†3306¬†indicate¬†MySQL client connection configuration necessary to make connection from¬†internal network.
  3. in SSH tunnel tab use following configuration:
    plink.exe location:   C:\Program Files\PuTTY\plink.exe
    SSH host + port:   22
    Username:             my_ssh_user_name
    Password:             my_ssh_user_password
    Local port:           3307
    • C:\Program Files\PuTTY\plink.exe is part of PuTTY software,
    • 3307 is any port used only to make connection from your computer to¬†, it can be changed to any unused port.
  4. save configuration,
  5. open connection.


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
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.

‚̧ԳŹūüíĽ ūüôā