connecting to a database server with socket through ssh tunnel

1,760 views
Skip to first unread message

fred...@seemann.net

unread,
Aug 20, 2011, 2:26:23 PM8/20/11
to Sequel Pro
Hi everyone!

I have the following problem. My web server is managed and I access my
database via localhost:/tmp/mysql5.sock. In addition I do not have
access to my database through the web. port 3306 is only opened
locally. When I try to connect on Sequel Pro via an SSH tunnel, it is
not possible because I can not connect through a ssh tunnel AND set a
specific socket.

Is there a solution or what can I do to access my database via socket
and an ssh tunnel?

Best regards,

Freddy

Jakob Egger

unread,
Aug 21, 2011, 1:32:00 PM8/21/11
to seque...@googlegroups.com
On 20.08.2011, at 20:26, fred...@seemann.net wrote:

I have the following problem. My web server is managed and I access my
database via localhost:/tmp/mysql5.sock. In addition I do not have
access to my database through the web. port 3306 is only opened
locally. 
When I try to connect on Sequel Pro via an SSH tunnel, it is
not possible because I can not connect through a ssh tunnel AND set a
specific socket.

Let me clear something up: Basically you can connect to MySQL servers via two methods:

a) via a unix socket
b) via TCP/IP

For security reasons, some people allow TCP connections to MySQL only from localhost. In that case, you can use Sequel Pro's SSH tunnel functionality.

Some people are even more paranoid and enable the "skip-networking" parameter in MySQL. This disables connections via TCP/IP, and you can connect only via unix sockets. The SSH Tunnel functionality in Sequel Pro does not work in this case.

If you say that "port 3306 is open only locally" I assume that skip-networking is not enabled, and you can use the SSH tunnel functionality in Sequel Pro. Just type 127.0.0.1 for the MySQL server.


Is there a solution or what can I do to access my database via socket
and an ssh tunnel?

If skip-networking is enabled, you are pretty much out of luck. If you could install the  "socat" program on the server, you could create an SSH tunnel  that connects to a unix socket, but this is pretty complicated. It's probably easier to get your admin to enable TCP-connections on the MySQL server.


Please also see the Sequel Pro docs for more on this topic, there's some pretty detailed info on SSH tunnels:

Best regards,
Jakob Egger
Reply all
Reply to author
Forward
0 new messages