VTV Lab

VTV Lab

Connect to MySQL server from HeidiSQL with SSH tunnel

I have spent few hours to figure out how to connect to my MySQL server running at Amazon EC2 with HeidiSQL. The reason I used HeidiSQL is its great friendliness coupled with many great features: copying the whole database from remote servers and vice versa or working with multiple servers at the same time. HeidSQL usually works like a charm with plain TCP connections. However, it gave me some hard time understanding how to use it with SSH enable option.

Very simple. You need to roughly understand how the whole picture is look like. The following two questions will help you when you have to fill in the configurations for the connection.

Amazon EC2 specific questions: Do I need to open the port 3306 for MySQL server to accept outside connections if I use SSH connection?

Answer: No, you don’t need. The reason is you are making an SSH connection to the SSH server at your Amazon EC2 from your local computer (where the HeidiSQL is), not directly making a connection to MySQL server anymore. More precisely, you have to make sure your SSH is running (this is as I know the default config of Amazon), opening the default port for SSH to accept outside connections: port 22 and that’s it.

HeidiSQL specific question: How do I enter the params in the Heidi?

Answer:

In the ‘Settings’ tab

1. In the dropdown list of ‘Network type’, please select SSH tunnel

2. Hostname/IP: localhost (even you are connecting remotely)

3. Username & Password: your mysql user and password

Next, in the tab SSH Tunnel:

1. specify plink.exe or you need to download it and specify where it’s located

2. Host + port: the remote IP of your SSH server(should be MySQL server as well), port 22 if you don’t change anything

3. Username & password: SSH username (not MySQL users)

4. You might ignore the password in the above step if you have the .ppk file.

After that, you can test the connection. Hope it works!

Single Post Navigation

10 thoughts on “Connect to MySQL server from HeidiSQL with SSH tunnel

  1. Pingback: Yasmin Melati » Connect to MySQL server from HeidiSQL with SSH tunnel

  2. Just wow & thanks! But better if you provide with example.

    Amazon EC2 username is: ec2-user and password is: Keypire fingerprint!

  3. Suchina on said:

    Thanks this was very useil

  4. it works

    thanks

  5. Thanks, this helped me.

  6. Ajit on said:

    good one and helped me this one in one go after so many attempts.

  7. The SSH Host must be IP address, cannot be FQDN

  8. Pingback: connecting to vagrant mysql db using heidisql | IT-Blog

  9. Thank you so much for sharing this solution! I learned SQL using Heidi in school, so wanted to use it with my home server, but was stumped until I read this!

Leave a reply to Nazmul H. Palash Cancel reply