6

Plain and simple, can anyone explain me how to connect to a mysql server through a proxy (socks4/5). Preferable via the mysql command line (although there are no options for that in the client).

If it's not possible through the mysql command line than ANY other method will work.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
Alexandru Luchian
  • 2,760
  • 3
  • 29
  • 41

3 Answers3

8

All you need is to install and configure tsocks (transparent socks). It's available in most if not all linux distibutions. Afterwards you only need to prefix your command with 'tsocks', for example: tsocks mysql -h -P .....

Jeka
  • 81
  • 1
  • 1
4

To my knowledge, it can't be done through the command line because the mysql command does not support proxy connections.

If both client and server are on a UNIX machine and one of them is accessible from the outside, I suggest using an SSH tunnel. It's basically a securely tunneled TCP connection that can be used for anything and the local mysql command can connect to the tunnel port easily.

If that's no option, you could write some kind of wrapper executable. For example, Java and Ruby have libraries that enable you to talk to SOCKS proxies and hook those sockets up to a MySQL or JDBC protocol implementation. What happens then depends entirely on what you have planned next.

Udo
  • 1,784
  • 11
  • 9
-1

If you've got admin access to the proxy server would there be much mileage in installing MySQL Proxy on it?

Twirrim
  • 406
  • 8
  • 16
  • If you have a specific followup question you should post it as a new question, not as an answer. In the top right is a "Ask Question" button to start a new question. – sth Jul 24 '09 at 04:09
  • 1
    That would be rather pointless, I was not asking a question for myself, but as a specific reply to the original questioner. – Twirrim Sep 28 '09 at 16:15
  • Actually, the correct "protocol" would be to make this comment on the question. – Stephen C Jan 21 '19 at 03:39