0

I've been trying to set up a SSH tunnel with VPN on my macbook with Big Sur 11.2, but it doesn't seem to work.

On my linux machine, I can simply turn on the VPN and make a SSH-tunnel. Then I can just connect to the MySQL server via port 3307. If I do the same on my macbook, the SSH tunnel does connect, but I can't connect to the MySQL server on the given port.

My exact steps are:

  1. Turn on VPN so I can access the server via SSH.
  2. Run ssh -g -L 3307:127.0.0.1:3306 user@ip_address in the terminal.
  3. Run mysql -u user -p -h [IP] -P 3307 to connect to the MySQL SSH tunnel.
  4. Error: Can't connect to MySQL server on '[IP]'.

Above works fine on my linux system, but not on my mac. I am able to SSH to the server with the command, but the tunnel itself is not working.

Is there some reason this is happening, and how should I proceed?

Jay Wit
  • 103
  • 4

1 Answers1

1

Your MySQL connection command tries to connect to the IP of the MySQL server, but that isn't available via the internet.

You need to use mysql -u user -p -h 127.0.0.1 -P 3307 command on the Macbook to connect via the tunnel.

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63
  • I don't know why I didn't not test it out.. I simply thought because it was VPN connected, I had to use that IP. Thanks! – Jay Wit Jan 06 '21 at 15:58