Avatar of cofactor
 asked on

How to set up SSH tunnel in MySQL Administrator GUI ?

How do I connect to a remote database through SSH tunnel in MySQL Administrator GUI tool ?

Can anybody please tell me the steps  to try ?

What is the solution ?
MySQL Server

Avatar of undefined
Last Comment

8/22/2022 - Mon

ssh -L 4545:localhost:3306 user@remotehost

using MySQL admin GUI you connect to localhost:4545
note that remotehost sshd configuration must allow port forwarding.

Hi arnold

Can you please clarify  few things  in your command

ssh -L 4545:localhost:3306 user@remotehost


Do I need to run this command  in command line (cmd)  ? ( I'm using Windows )  ?
I need to put this command somewhere in the MySQL admin GUI ? (if so where ?)


 user  is the user id  of the remote box   ?  
user  is the user id  of the remote database   ?  

Q3:  remotehost  is the IP of the remote box ?

Q4: You are not using   password of  remote box ...don't we require the remote box password ?

You can use putty as the ssh client.

You would use local for the type of tunnel if you want acces from local to remote.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck

Hi arnold,

What I don't understand is  ..do I need to fire this command  in Windows command line ?
ssh -L 4545:localhost:3306 user@remotehost

Yes/No ?

No. On windows you do not have an ssh command unless you have cygwin install.

The link I provided is a reference to putty (http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html) which is an ssh client that you can run on your windows system and configure to have a tunnel upon connection to the remote system. Once the putty/ssh connection is established you will be able to access the mysql service on the remote system usng mysql admin GUI.
You would select the local option. The source port represents the local port to which you will configure mysql admin to connect (localhost:sourceport) with the destination as localhost:3306. Note localhost used in destination is a relative reference to the remote server.
You can use this tunnel, to establish connections to other systems/services on the remote network. Destination server:port will route.

I have  made a SSH connection to remote box using putty.
Port opened is  10000

When I put  the following details in the  MySQL GUI tool ..it does not connect.

DB :  localhost
port: 10000
username: db_username

It does  not connect.

I also tried with this ..

DB :  localhost
port: 3306
username: db_username

It does  not connect.
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.

Establish an ssh connection.
Then click on putty to get the drop down and select change.
Navigate to ssh, tunnels.
Add a local source 1234
destination localhost:3306

Apply the change.
Open a new session in putty choose to use the telnet to local host port 1234
Do you get a mysql response?

The issue might be that the username/password have no access rights on localhost.

You've not said what error if any was received.

Its not working .

I use SQLYog .  in SQLYog I connect remote database easily.  You may see how I do it   in SQLYog ..Please see the steps so that you'll be able to know my hardware systems.

In putty :
Host:  <IP1>  port : 22
Tunnel:    Add source port: 10000   Destination: <IP2>:  22

Click connect on Putty. ...... Give username / pwd of the box  <IP2>   in putty window .....SSH connection established.

Now in SQLYog editor there is a SSH tab ...I put SSH  host: localhost   port: 10,000
and  in MySQL connection I put host: localhost  port: 3306

I can connect to remote mysql database....no problem in SQLYog

However I want to  switch to MySQL GUI . .. .I am not sure how do I connect through MYSQL GUI for the same system.

Can you please tell how do I connect to the remote DB  using MySQL GUI  tunnel with this system architecture ?

Please follow the instruction provided earlier.
In putty, add a tunnel local source 10000
Destination localhost:3306
Establish the ssh session.
Open mysql GUI
Connection to localhost:10000

Is the mysql to which you want to connect running on the system to which you establish the first ssh connection?

Can you provide a clear picture?
Local workstation system from which you want to run mysql GUI.
Remote system to which you establish an ssh session with a local mysql that you want to connect to?
Or do you have yet another system where mysql runs that is on the remote LAN?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes

>>> do you have yet another system where mysql runs that is on the remote LAN?


I have two  remote boxes . on second remote box mysql runs.

I use Forticient VPN to enter into remote LAN  and then do  the above SSH connection in SQLYog.

Please see the steps I posted  for SQLYog which works fine,.  I want to do the same for MYSQL Gui...... I like MySQL GUI

View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.

This worked fine.  Thanks.