Featured image of post Accessing Internal Network MySQL Database Locally via MobaXterm Xshell Tunneling

Accessing Internal Network MySQL Database Locally via MobaXterm Xshell Tunneling

Connecting to internal network MySQL databases directly isn't feasible for local development

Context

The test environment database resides in an internal network, while my computer can only connect via a jump server. To enable local code access, I tested MobaXterm for SSH tunneling.

Installation

  • Choose between the portable version (no installation) or installer. I selected the installer for straightforward setup.

Configuration

  1. Open MobaXterm, navigate to Tunneling > New SSH tunnel

  1. Configure three key sections:
    • Internal database server IP/port
    • Jump server SSH credentials (IP, user, port)
    • Local port (choose an unused port)

  1. Click the key icon to configure SSH key authentication for the jump server.
  2. Restart tunnels via Stop all tunnels > Start all tunnels to apply changes.

Verification

Check port forwarding status:

# Check port 3306 listening status
netstat -ano | findstr "3306"
TCP    0.0.0.0:3306           0.0.0.0:0              LISTENING       18356
TCP    [::]:3306              [::]:0                 LISTENING       18356

# Test MySQL service connectivity
telnet 127.0.0.1 3306
N
 5.7.22-log [xxx]mysql_native_password
# Random characters indicate successful tunneling

Update database connection string to:
mysql:username:password@tcp(127.0.0.1:3306)/database

  • This method also works for Redis and other internal services.

Xshell Configuration

Similar process applies to Xshell: