Solved

How to set up SSH tunnel  in MySQL Administrator GUI ?

Posted on 2013-01-04
12
505 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 77

Expert Comment

by:arnold
ID: 38745830
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
ID: 38746077
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 77

Expert Comment

by:arnold
ID: 38746096
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:cofactor
ID: 38746210
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 77

Expert Comment

by:arnold
ID: 38746243
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
ID: 38749891
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
 
LVL 77

Expert Comment

by:arnold
ID: 38749931
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
ID: 38762379
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 77

Expert Comment

by:arnold
ID: 38762803
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
ID: 38765704
>>> 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 77

Accepted Solution

by:
arnold earned 300 total points
ID: 38765742
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
ID: 38767974
This worked fine.  Thanks.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

816 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

8 Experts available now in Live!

Get 1:1 Help Now