Using SSH tunnel to access non localhost remote mysql server

[expired user #5360]'s profile image [expired user #5360] posted 13 years ago in General Permalink
Can anyone help me with the following problem:

I can successfully have a ssh tunnel connection with putty and access it with HeidiSQL from localhost but now I want to use just HeidiSQL (with plink).

Putty + HeidiSQL setup:

Putty:

Session > Hostname > ssh.domain.com
Session > Port > 22
Session > Connection type > SSH

Connection > SSH > Tunnels > Source port > 3307
Connection > SSH > Tunnels > Destination > abc:3306

(note the abc, this is a local server on the remote network)

HeidiSQL:

Settings > Hostname > localhost
Settings > User > XYZ
Settings > Password > ***
Settings > Port > 3307

With this setup I'm successfully connected:

HeidiSQL >
local computer localhost:3307 >
remote ssh server ssh.domain.com >
remote server abc:3306

How is this possible with HeidiSQL?

I always get the message: SQL Error (2003): Can't connect to MySQL server on 'localhost' (10061)

What is this localhost? Is this the remote server localhost?

I want to connect to abc:3306 and not localhost:3306 on the remote server.

The remote server is only a ssh server without mysql... The server WITH mysql is in this case abc:3306

Is this not possible with HeidiSQL? Why does it work with putty but not with HeidiSQL + plink? Did I something wrong?
[expired user #5360]'s profile image [expired user #5360] posted 13 years ago Permalink
I got plink working with the following command:

plink -P 22 -L localhost:3307:abc:3306 -pw "password" username@ssh.domain.com

localhost:3307 is here your local computer

abc:3306 is here the remote mysql server (accessed through the remote ssh server)

How can I establish this with HeidiSQL?

It seems that nowhere you can add the remote local server abc, not in settings tab and not in ssh tunnel tab. And HeidiSQL always use localhost as remote mysql server, thus like this:

plink -P 22 -L localhost:3307:localhost:3306 -pw "password" username@ssh.domain.com

Is it true the second localhost can not be changed with HeidiSQL?
[expired user #5360]'s profile image [expired user #5360] posted 13 years ago Permalink
Got it, everything just works fine. HeidiSQL is great!

The default plink timeout (5) was not enough, set it to 15 and everything works like expected. SSH server was just sooo slooow.

Settings > Hostname > abc (not localhost as for putty tunnel)
Settings > User > username (database username)
Settings > Password > ***
Settings > Post > 3306 (remote database server port)
Settings > Databases > username_database1;username_database2

SSH tunnel > SSH > ssh.domain.com 22
SSH tunnel > User > username (ssh server username, can be the same as database username, depends on your host)
SSH tunnel > Password > ***
SSH tunnel > timeout > 15
SSH tunnel > Local port > 3307 (or whatever, this is the port used on you computer, if you have a local mysql server running do not use 3306 here)

Thats all...
ansgar's profile image ansgar posted 13 years ago Permalink
Hehe, nice monologue here. Thanks a lot for sharing that! SSH tunnelling can be quite confusing.
[expired user #5832]'s profile image [expired user #5832] posted 13 years ago Permalink
so… i have this bug and i cry (( please, fix it
[expired user #5851]'s profile image [expired user #5851] posted 13 years ago Permalink
Fixed it by using the plink version 0.61!
The problem was, that Heidi downloadable plink version asked always for a password (calling plink in the command line).
The plink version 0.61 doesn't anymore.
[expired user #10413]'s profile image [expired user #10413] posted 7 years ago Permalink

Thanks for sharing. It's work fine. Thanks HeidiSQL

Please login to leave a reply, or register at first.