Remote MySQL on Windows still needs an SSH tunnel when port 3306 is not public. The bastion idea matches every other OS: encrypt traffic through SSH, then speak MySQL on the far side. Windows is the tooling split. You can run OpenSSH in a terminal, keep a PuTTY session open, or let the GUI start the tunnel itself.
Choose OpenSSH, PuTTY, or an in-app tunnel
Pick the path that matches the client you already run.
| Method | What starts the tunnel | GUI host and port | Stay-open rule |
|---|---|---|---|
OpenSSH (ssh.exe) |
PowerShell or Windows Terminal | 127.0.0.1 and a free local port such as 3307 |
The ssh -N window must stay running |
| PuTTY | Saved session with a Local forward | Same: 127.0.0.1:3307 |
The PuTTY window must stay open |
| In-app tunnel | The client SSH checkbox | Internal MySQL host as seen from the bastion, often 127.0.0.1:3306 |
No extra terminal if the client owns ssh.exe |
HeidiSQL on Windows can drive PuTTY's plink.exe. MySQL Workbench and TabulaSQL expect OpenSSH-style private keys. Mixing .ppk files with ssh.exe is the usual failure, not the bastion itself.
If you want a client that stores the tunnel next to the MySQL login, TabulaSQL is a free desktop option with a Connect through SSH tunnel checkbox. For the field-by-field mental model of bastion versus database host, the earlier MySQL GUI with SSH tunnel guide still applies. This page stays on Windows setup.
OpenSSH local forward
Windows 10 and 11 ship OpenSSH as an optional feature. Confirm it before you blame the GUI.
- Open PowerShell and run
where.exe ssh. You wantC:\Windows\System32\OpenSSH\ssh.exe. - If that prints nothing, open Settings, search Optional features, add OpenSSH Client, then open a new terminal.
- Test a normal login:
ssh -p 22 [email protected]. - Start the forward only after that login works:
ssh -N -L 3307:127.0.0.1:3306 [email protected]
-N means no remote shell. 3307 is your local listen port. The right-hand 127.0.0.1:3306 is MySQL as the bastion sees it. If the database lives on a private host, change that destination to 10.0.1.40:3306.
Keep this window open. In the GUI, turn SSH off. Set Host to 127.0.0.1, Port to 3307, then your MySQL username and password. Skip localhost here. On many Windows stacks localhost resolves to ::1, while the forward is bound to IPv4 only.
Use 3307 (or another free port) when XAMPP, Docker Desktop, or a local MySQL service already owns 3306. A bind error on the OpenSSH side looks like the GUI failing later.
Private keys live under C:\Users\you\.ssh\. Point -i at id_ed25519 or id_rsa, not the .pub file. Prefer the agent if you do not want the passphrase on every connect: Get-Service ssh-agent, start it as administrator if needed, then ssh-add $env:USERPROFILE\.ssh\id_ed25519.
PuTTY local forward
PuTTY is still the path when a Windows-only client talks to plink, or when your team already stores .ppk files. Set Host Name to bastion.example.com and Port to 22 unless your provider uses something like 7822. Connection type stays SSH.
Open Category, Connection, SSH, Tunnels. Source port is 3307. Destination is 127.0.0.1:3306. Leave Local and Auto selected, then click Add until the list shows L3307 127.0.0.1:3306. Under Auth, Credentials, browse to the .ppk. Pageant can hold the unlocked key if you use it daily. Save the session as bastion-mysql and click Open. Leave that window running.
Point the GUI at 127.0.0.1 port 3307 with SSH disabled in the client. Closing PuTTY drops every query.
Convert keys when you switch tools. PuTTYgen opens a .ppk, then Conversions, Export OpenSSH key, which writes a file TabulaSQL and ssh.exe can use. Going the other way, Load the OpenSSH private key in PuTTYgen and Save private key to get a .ppk.
In-app tunnel in TabulaSQL
Skip the extra terminal when the client can spawn ssh.exe for you.
- New Connection. Driver: MySQL / MariaDB.
- Name the saved profile. Host is the MySQL address from the bastion, often
127.0.0.1if mysqld runs on that same box, or a private IP such as10.0.1.40. Port:3306. Username and Password are the database user, not the SSH user. - Check Connect through SSH tunnel.
- SSH host:
bastion.example.com. SSH port:22. SSH user:deploy. - Authentication: Private key. Browse to
C:\Users\you\.ssh\id_ed25519. Do not pick the.pubfile and do not paste a PuTTY.ppk. - Click Test connection, then save.
Password as the SSH method needs sshpass, which Windows does not ship. On this OS, key auth is the reliable choice. The client looks for ssh on PATH, so Optional features must already include OpenSSH Client. SQLite file databases have no SSH option.
After the tunnel is up you can browse tables, run queries, and use Safe Lock before writes, the same as a local connection. Edit the saved connection if the bastion host or key path changes. TabulaSQL reconnects instead of leaving a stale forward.
Windows failures that look like MySQL
Tunnel up, GUI still angry: try 127.0.0.1 instead of localhost. Error 2002 or 2013 with a local forward usually means the listen port is wrong, the PuTTY or OpenSSH window closed, or MySQL on the far side is not on 3306.
SSH works in Terminal, GUI key rejected: the path is a .ppk, a .pub, or a key still locked with a passphrase the client never prompted for. Unlock once with ssh-add, or export an OpenSSH key without wrapping it in PuTTY format.
GUI SSH checkbox on and Host set to 127.0.0.1 while PuTTY already forwards 3307: you stacked two tunnels. Pick one method. External forward: checkbox off, port 3307. In-app: checkbox on, port 3306, Host equal to internal MySQL.
MySQL user errors after SSH succeeds: grants are user@host from the bastion's view. A user allowed from your laptop IP is not automatically allowed from 127.0.0.1 on the server.
Need a Windows client that is not Workbench? The free MySQL client for Windows and Linux roundup lists license and OS facts without repeating this tunnel setup.