Desktop database apps like HeidiSQL, MySQL Workbench and TablePlus are nicer than a web page for big queries and bulk editing. On our servers, the database doesn't accept direct connections from the internet -- instead, you connect through an SSH tunnel on port 22. This guide explains how an SSH tunnel to MySQL works and how to set one up in each of those apps, plus plain command-line instructions for everything else.
Why a tunnel, and not a direct connection?
Your databases only accept connections from the server itself, and Remote MySQL (opening the database to specific IP addresses) isn't offered. That's deliberate: databases exposed to the internet get hammered by password-guessing bots, and ordinary MySQL connections aren't encrypted by default.
An SSH tunnel gets you the same result safely. Your app logs in to your hosting account over SSH (encrypted, on port 22), and SSH quietly forwards the database connection through that encrypted link to the database on the server. As far as the database is concerned, the connection comes from the server itself, just like your website's does.
In practice you give your app two sets of login details:
| Part | Host | Port | Username | Password |
|---|---|---|---|---|
| SSH (getting onto the server) | Your domain, e.g. example.com (or secure.instantaccess.net) | 22 | Your cPanel username | Your cPanel password, or an SSH key |
| MySQL (once you're there) | 127.0.0.1 | 3306 | Database user, e.g. username_dbuser | That database user's password |
Note the MySQL host: it's 127.0.0.1, meaning "this server", as seen from the far end of the tunnel. Use 127.0.0.1 rather than the word localhost in these apps -- some clients treat localhost specially and skip the tunnel.
Before you start
- Make sure SSH works. Your account needs shell access. Test it first from Windows Terminal, PowerShell or Mac Terminal with
ssh username@example.com. If logins are refused with the correct password, open a ticket and ask for shell access. - Have a database user ready. Create one in Databases > Manage My Databases and add it to the database with the privileges it needs. For someone who only needs to read data, you can tick just SELECT instead of ALL PRIVILEGES.
- Consider an SSH key. Keys are safer than passwords and save typing. Our SSH guide shows how to create one and authorize it in Security > SSH Access > Manage SSH Keys.
- Don't guess passwords repeatedly. Several failed SSH logins in a row can get your IP address temporarily blocked by the firewall.
HeidiSQL (Windows)
- Open HeidiSQL and click New in the Session manager.
- On the Settings tab, set Network type to MariaDB or MySQL (SSH tunnel).
- Still on Settings, enter Hostname / IP:
127.0.0.1, User: your database user (e.g.username_dbuser), Password: the database user's password, Port:3306. Optionally pick your database under Databases. - Open the SSH tunnel tab. Choose the SSH program (HeidiSQL ships with
plink.exe; recent versions can also use Windows' built-inssh.exe). - Enter SSH host + port: your domain and
22. Username: your cPanel username. Either the Password (your cPanel password) or a Private key file. Withplink.exe, the key must be in PuTTY's.ppkformat -- convert it with PuTTYgen if needed. - Leave Local port at
3307(any free port works). - Click Save, then Open. The first time, you may be asked to accept the server's host key.
MySQL Workbench (Windows, Mac, Linux)
- On the home screen, click the + next to MySQL Connections.
- Give it a Connection Name and set Connection Method to Standard TCP/IP over SSH.
- Fill in:
- SSH Hostname:
example.com:22 - SSH Username: your cPanel username
- SSH Password (click Store in Vault / Store in Keychain) or SSH Key File: the path to your private key
- MySQL Hostname:
127.0.0.1 - MySQL Server Port:
3306 - Username: your database user; Password: click Store in Vault and enter the database user's password
- SSH Hostname:
- Click Test Connection. Accept the host key if asked. You should see "Successfully made the MySQL connection".
- Click OK, then double-click the new tile to connect.
Workbench may warn that the server is MariaDB rather than MySQL, or that its version isn't officially supported. Click Continue Anyway -- everyday browsing, queries and exports work fine.
TablePlus (Mac, Windows)
- Click Create a new connection and choose MariaDB (or MySQL).
- Enter a Name, then Host:
127.0.0.1, Port:3306, User and Password: your database user's details, and optionally the Database name. - Click Over SSH to show the SSH fields.
- Enter Server: your domain, Port:
22, User: your cPanel username, and either the Password or tick Use SSH key and choose your private key file. - Click Test. When the fields turn green, click Connect.
Any other app: open the tunnel yourself
If your app has no SSH option (or you use DBeaver, DataGrip, Sequel Ace, a script, or the mysql command), open the tunnel from a terminal and point the app at your own computer:
ssh -N -L 3307:127.0.0.1:3306 username@example.com
-L 3307:127.0.0.1:3306means "listen on port 3307 on my computer, and send it to 127.0.0.1 port 3306 on the server".-Nmeans "don't open a shell, just keep the tunnel up". The window will look like it's doing nothing -- leave it open.
Now connect your app to host 127.0.0.1, port 3307, with the database user and password. For example:
mysql -h 127.0.0.1 -P 3307 -u username_dbuser -p username_dbname
Press Ctrl+C in the tunnel window when you're finished. On Windows, the same ssh command works in PowerShell or Windows Terminal. With PuTTY, add the forward under Connection > SSH > Tunnels: source port 3307, destination 127.0.0.1:3306, then click Add before opening the session.
Troubleshooting
SSH login fails: "Permission denied" or "Access denied"
The SSH part uses your cPanel username and password (or key) -- not the database user. Check that shell access is enabled on your account and that any key you're using is authorized in Manage SSH Keys. Test with a plain ssh username@example.com in a terminal first; if that fails, the app will too.
The connection times out
Your IP address may be blocked after failed logins, or your office or public Wi-Fi may block outgoing SSH. Try another network (a phone hotspot is a quick test). If it's a block on our side, open a ticket with your IP address from whatismyipaddress.com.
SSH works, but MySQL says "Access denied for user"
Now it's the database details. Use the full database username with the username_ prefix, check the user is added to the database in Manage My Databases, and set a fresh password there if in doubt. Make sure the MySQL host is 127.0.0.1. Our MySQL login errors guide covers each case.
"Address already in use" or "bind: Permission denied" on port 3307
Something on your computer is already using that local port -- often a local MySQL installation or an old tunnel. Pick another local port, such as 3308, in both the tunnel and the app.
The app connects but I can't see my database
The database user can only see databases it has been added to. Add it in Manage My Databases > Add User To Database, then reconnect.
Common questions
Can I turn on Remote MySQL instead?
No -- Remote MySQL isn't offered on our hosting. The SSH tunnel is the supported way to reach your database from your own computer, and it's more secure.
Can a developer connect without my cPanel password?
Ask them for their public SSH key and authorize it in Security > SSH Access > Manage SSH Keys, and give them a database user for just the database they need. Remove the key and the user when the work is done. Keep in mind that SSH access to your account can reach all of its files.
Should I edit my live database from a desktop app?
You can, but changes are instant and there's no undo. Export a copy first, and be careful with bulk updates.
Related guides
- How to Use SSH, SSH Keys and Terminal in cPanel
- How to Create a MySQL Database and User in cPanel
- How to Change a MySQL Database User's Password
- How Can I White List Myself in the Firewall?
- How to Import and Export a Database with phpMyAdmin
Still stuck? Open a support ticket and the Instant Access Internet Services team will help.
