distal-attribute
distal-attribute
distal-attribute
distal-attribute

Using SSH tunnel to access non localhost remote mysql server

User, date Message
Written by e-mike
3 years ago
Category: General
4 posts since Sat, 04 Dec 10
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?
Written by e-mike
3 years ago
4 posts since Sat, 04 Dec 10
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?
Written by e-mike
3 years ago
4 posts since Sat, 04 Dec 10
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...
Written by ansgar
3 years ago
4801 posts since Fri, 07 Apr 06
Hehe, nice monologue here. Thanks a lot for sharing that! SSH tunnelling can be quite confusing.
Written by trin
3 years ago
3 posts since Fri, 15 Jul 11
so… i have this bug and i cry (( please, fix it
Written by h.ruholl
3 years ago
1 posts since Tue, 26 Jul 11
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.
 

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