如何通过跳板服务器使用Sequel Pro/Workbench连接MySQL?
Got it, let's solve this—since your jump server is already whitelisted for the client's server, we can use SSH port forwarding (either pre-established or directly within your MySQL tool) to connect Sequel Pro or Workbench to the client's database. Here are the step-by-step methods:
Option 1: Pre-Establish a Local Port Forward Tunnel (Works for Both Tools)
This creates a local port on your machine that routes traffic through the jump server straight to the client's MySQL port. Run this in your terminal:
ssh -L 3306:client.com:3306 -i /path/to/your/jump-server-key user@jump.com
Breakdown of the command:
-L 3306:client.com:3306: Maps your local port 3306 to the client's MySQL port (3306) via the jump server. If your local 3306 is in use, swap it for another port like 3307 (change both numbers to 3307).-i /path/to/your/jump-server-key: Path to the private key for your jump server (omit this if you use password auth instead).user@jump.com: Your login credentials for the jump server.
Once this tunnel is running, you can connect to MySQL as if it's hosted locally (e.g., connect to localhost:3306 in your tool).
Option 2: Directly Configure SSH Tunnel in Sequel Pro
Sequel Pro has built-in SSH tunnel support, so you don't need a separate terminal command. Here's how to set it up:
- Open Sequel Pro and select the SSH connection type.
- Fill in the MySQL section:
- MySQL Host:
client.com(the client's server where MySQL runs) - Username: Your MySQL username on the client's server
- Password: Your MySQL password (leave blank if using key auth for MySQL)
- Port: 3306 (adjust if the client uses a non-standard MySQL port)
- MySQL Host:
- Switch to the SSH tab:
- SSH Host:
jump.com(your jump server's hostname/IP) - SSH User: Your username on the jump server
- SSH Key: Select the private key file for the jump server (use this instead of password auth for better security)
- SSH Host:
- Click Connect—Sequel Pro will handle the tunnel automatically.
Option 3: Directly Configure SSH Tunnel in MySQL Workbench
MySQL Workbench also supports SSH tunneling natively. Follow these steps:
- Open Workbench and click the + icon to create a new connection.
- Name your connection something descriptive (e.g., "Client MySQL via Jump Server").
- Set the Connection Method dropdown to Standard TCP/IP over SSH.
- Fill in the SSH details:
- SSH Hostname:
jump.com:22(22 is the default SSH port—adjust if your jump server uses a different one) - SSH Username: Your jump server username
- SSH Key File: Browse to your jump server's private key (or use password auth if preferred)
- SSH Hostname:
- Fill in the MySQL details:
- MySQL Hostname:
client.com - MySQL Server Port: 3306 (adjust if needed)
- Username: Your MySQL username on the client's server
- Password: Your MySQL password (click Store in Vault to save it for future use)
- MySQL Hostname:
- Click Test Connection to verify it works, then save the connection.
Quick Troubleshooting Tips
- If you get a "connection refused" error:
- Double-check that the jump server's IP is in the client's SSH whitelist.
- Ensure the client's MySQL server allows connections from the jump server's IP (check MySQL's
usertable privileges—your MySQL user should have access fromjump.comor a broader range if necessary). - Confirm all ports and credentials are correct for both the jump server and MySQL.
- If your local port 3306 is occupied, use a different local port (like 3307) in the tunnel command or tool settings, then connect to
localhost:3307instead.
内容的提问来源于stack exchange,提问作者Mullarkb

