How to connect to a MySQL database over a SSH tunnel with HeidiSQL

How to connect to a MySQL database over a SSH tunnel with HeidiSQL

How to connect to your MySQL database over SSH with HeidiSQL to get rid of that useful but not very handy PHPMyAdmin.

HeidiSQL a very loyal MySQL client in your toolbox

HeidiSQL is one of the best free database clients for Windows and works pretty well too under Linux too when using Wine.

To make this work it is vital that your hosting provider offers you to open a connection over SSH to your webspace. To make the VPN tunnel work this article assumes that you have your login credentials to your SSH connection and database available.

Step 1. Create a new connection in HeidiSQL

First thing you have to do is to create a new session in the session manager that can be accessed from the "File" menu.

Now dropdown the network type and select "MySQL (SSH Tunnel)".

SSH tunnel with HeidiSQL

Step 2. Modify the settings in the Settings tab

SSH tunnel with HeidiSQL

Now fill the following details:

  1. Enter here the user ID that your use to connect to your remote MySQL server database.
  2. Enter here the password that corresponds with that same user.

This section is about connecting to the database, while the SSH tunnel tab is about connecting to your admin.

Step 3. Modify the settings in the SSH tunnel tab

SSH tunnel with HeidiSQL

HeidiSQL requires plink, a small program to make the connection with the SSH tunnel. It is from the maker of Putty. If you don't have it installed, just click on the "Download plink.exe" link and download the program for your environment (Linux/Windows, 32bits/64bits). The program is only 550Kb and it is best to put is somewhere where you can easily find it, like in c:\tools or something other short. You enter the plink.exe with location in the plink.exe location field.

Now fill the following details as well:

  1. The port that you have received from your provider to have access over the SSH tunnel. This could be something a value like 7685, but it depends on your provider.
  2. The user id you received from your provider to connect to your hosting backend/admin. This is mostly the user that came with the installation letter. I think you get lucky with the credentials to access Direct Admin or any other admin panel of your provider.
  3. Here you put the password of that same user.{.list-style}

This has nothing to do with the database itself. It is about connecting to your hosting admin through SSH.

Step 4. Modify the settings in the Advanced tab

SSH tunnel with HeidiSQL

An experience related remark

I've noticed that sometimes the connection gets lost with the server. Therefor it is wise to set the "Ping every X seconds" to a value of 15 (seconds). Modify this to a value that best fit your situation.

Step 5. Get connected

Finally save your just created session and if everything turns out well you won't need PHPMyAdmin anymore and use all the convenience that comes with HeidiSQL.

Recommended: Donate the developer
Using HeidiSQL is free, but if you like HeidSQL than I recommend you donate a token of appreciation to the developer Ansgar Becker Donate

More from same category