VTV Lab

VTV Lab

Archive for the tag “amazon”

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!

Advertisements

Post Navigation