Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I SSH to MySQL with the GUI tools?

I have a ubuntu server which I've locked down to only HTTP, HTTPS and SSH (port 30000). On this box I have a MySQL server which 99.9% of the time is only used locally. Every now and then I want to connect to the MySQL instance with the GUI tools, but without touching the firewall.

Therefore, it is possible to set things up so that I can connect to the MySQL box with the SSH connection? Is there any sort of port forwarding magic I can do?

like image 383
Neil Middleton Avatar asked May 13 '09 17:05

Neil Middleton


4 Answers

I'd suggest using HeidiSQL if you are on Windows. It handles the SSH tunnel by itself (you just need to download the plink.exe utility).

In my humble opinion, it is the best MySQL tool out there (and it's free and open source).

like image 73
David Morales Avatar answered Sep 23 '22 06:09

David Morales


ssh -L localport:127.0.0.1:remoteport user@remotehost

where localport is an unbound port on your local system, remoteport is the port on which MySQL listens, 127.0.0.1 is the loopback address on your remote system, user is your user name and remotehost is the address of the remote system.

Then point your MySQL client to 127.0.0.1:localport. The connection will be forwarded over the SSH tunnel to the remote port.

like image 29
Daniel Cassidy Avatar answered Nov 10 '22 04:11

Daniel Cassidy


If you are using Windows or Unix on your local machine, PuTTY is an excellent tool for this. Here's a tutorial on port forwarding:

http://www.cs.uu.nl/technical/services/ssh/putty/puttyfw.html

like image 4
cliff.meyers Avatar answered Nov 10 '22 03:11

cliff.meyers


Set up a tunnel using the SSH client to map a local port, through the tunnel, to a port on the remote machine, then connect to the local port using the client.

man ssh will have the gory details, but you're probably better off searching the web for something a wee bit easier to read.

like image 3
Rob Avatar answered Nov 10 '22 03:11

Rob