8

I'm trying to connect to a remote MySQL server (with TCP access limited to a specific IP) using port forwarding via SSH, but still haven't figured out how to do it.

Here's what I intend to do:

Local[A] ---> Proxy[B] ---> Remote MySQL[C] 

[A] Local machine with Windows

[B] CentOS machine with IP 123.123.123.1 (with it's own MySQL running, btw)

[C] Remote MySQL server with IP 123.123.123.1 authorized on port 3306

How to achieve this?

2
  • Do machines B and C really have the same IP address? Commented Apr 28, 2010 at 21:20
  • Take a look at this question as it's the same concept: serverfault.com/questions/134289 Commented Apr 28, 2010 at 21:34

1 Answer 1

10

Use PuTTY's port forwarding to forward local port 3306 to port 3306 of machine C, connecting to machine B. If using the command line ssh use:

ssh -L 3306:machineC:3306 username@machineB 

then connect to MySQL via localhost:3306.

1
  • Depending on the exact syntax of the configuration most mysql clients will interpret "localhost" as meaning use the AF_UNIX (filesystem) socket NOT a TCP socket. 127.0.0.1:3306 should be used. Commented Jun 17, 2024 at 10:06

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.