Solved

How to set up SSH tunnel  in MySQL Administrator GUI ?

Posted on 2013-01-04
12
501 Views
Last Modified: 2013-01-11
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
Comment
Question by:cofactor
  • 6
  • 6
12 Comments
 
LVL 76

Expert Comment

by:arnold
Comment Utility
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
 

Author Comment

by:cofactor
Comment Utility
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
 
LVL 76

Expert Comment

by:arnold
Comment Utility
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
 

Author Comment

by:cofactor
Comment Utility
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
 
LVL 76

Expert Comment

by:arnold
Comment Utility
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
 

Author Comment

by:cofactor
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 76

Expert Comment

by:arnold
Comment Utility
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
 

Author Comment

by:cofactor
Comment Utility
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
 
LVL 76

Expert Comment

by:arnold
Comment Utility
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
 

Author Comment

by:cofactor
Comment Utility
>>> 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
 
LVL 76

Accepted Solution

by:
arnold earned 300 total points
Comment Utility
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
 

Author Closing Comment

by:cofactor
Comment Utility
This worked fine.  Thanks.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

A lot of articles have been written on splitting mysqldump and grabbing the required tables. A long while back, when Shlomi (http://code.openark.org/blog/mysql/on-restoring-a-single-table-from-mysqldump) had suggested a “sed” way, I actually shell …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now