• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 669
  • Last Modified:

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 ?
0
cofactor
Asked:
cofactor
  • 6
  • 6
1 Solution
 
arnoldCommented:
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.
0
 
cofactorAuthor Commented:
Hi arnold

Can you please clarify  few things  in your command

ssh -L 4545:localhost:3306 user@remotehost


Q1:

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



Q2:

 user  is the user id  of the remote box   ?  
OR
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 ?
0
 
arnoldCommented:
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.
http://oldsite.precedence.co.uk/nc/putty.html
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
cofactorAuthor Commented:
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 ?
0
 
arnoldCommented:
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.
0
 
cofactorAuthor Commented:
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
password:db_password


It does  not connect.





I also tried with this ..

DB :  localhost
port: 3306
username: db_username
password:db_password

It does  not connect.
0
 
arnoldCommented:
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.
0
 
cofactorAuthor Commented:
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 ?
0
 
arnoldCommented:
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?
0
 
cofactorAuthor Commented:
>>> do you have yet another system where mysql runs that is on the remote LAN?

Yes.

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
0
 
arnoldCommented:
You have to setup the tunnel within putty as follows
Localport 1234
Destination: remotesystemwithmysql:3306
Then connect to the remotehost.

A connection from mysql administrator localhost:1234 will get your connection through the ssh tunnel to the remotehost and to the remotesystemwithmysql:3306.

Your prior example creates a tunnel and then sqlyog then establishes an ssh session within the putty tunnel with yet another tunnel.
0
 
cofactorAuthor Commented:
This worked fine.  Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 6
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now