1

How can I connect to a MySQL server via SSH Tunnel and get from the server the UNIX socket in Datagrip?

I found this partial solution, that helps me to configure SSH Tunnel but not get the socket file from the server. How to connect to database through SSH using DataGrip

enter image description here

enter image description here

The server is MariaDB and I tried to use this information too but doesn't work

https://intellij-support.jetbrains.com/hc/en-us/community/posts/360010247880-How-to-connect-to-mariadb-via-unix-socket-

enter image description here

Chris Sum
  • 123
  • 1
  • 2
  • 11

1 Answers1

2

unix socket is not forwarded via SSH tunnel unless you perform some additional steps. the best approach is to use socat. something like that before connection:

/usr/bin/socat "UNIX-LISTEN:$SOCKET_DIR/mariadb-remote1.sock,reuseaddr,fork" \
EXEC:'/usr/bin/ssh -F /etc/sshssh_config -l root <remote1 host> -p 22 /usr/bin/socat STDIO UNIX-CONNECT\:/run/mariadb/mariadb.sock'

Here and here you can find more useful information.

Yuri Win
  • 1,348
  • 4
  • 10
  • You are my savior, thank you very much! That works! I used the simple way of socat in my server. `socat -v tcp-l:3308,bind=localhost,reuseaddr,fork unix:/run/mysqld/mysqld.sock` – Chris Sum Jul 31 '21 at 06:02