Can I SSH to MySQL with the GUI tools?

时光毁灭记忆、已成空白 提交于 2019-12-18 15:33:08

问题


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?


回答1:


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.




回答2:


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




回答3:


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.




回答4:


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).




回答5:


There two ways to use the GUI mysql tools on a remote MYSQL machine.

I'm assuming the remote machine is running linux.

Option 1.

SSH port forwarding.

ssh -L 3306:proxy:3306 username@remotehost

Basically you forward port 3306 on your local machine to 3306 on your remote machine, then you tell your graphical MYSQl tool to connect to localhost:3306 and you assume that your remote machine is listening on the standard port of 3306

http://magazine.redhat.com/2007/11/06/ssh-port-forwarding/

Also ssh -D 3306 username@remotehost should be similar

Option 2.

If you are running xserver on your remote machine and have the GUI tools installed on your remote machine you can tunnel your GUI over the SSH connection.

ssh -X username@remotehost and then start your GUI tools over on remote machine from the command line.




回答6:


SSH/HTTP tunneling in SQLyog is good. There is public/private key authentication which adds an additional layer of security.




回答7:


I suggest looking to phpMyAdmin a web based tool to administrate MySQL, and is very good (requires PHP). It can be installed through the normal Ubuntu methods (e.g. Synaptic)

Or do X tunnelling with SSH as mentioned above.



来源:https://stackoverflow.com/questions/859218/can-i-ssh-to-mysql-with-the-gui-tools

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!