Skip to content

Opening remote MySQL on cPanel without leaving 3306 wide open

cPanel's Remote MySQL feature adds hosts to a per-account allowlist. What it does not do is configure TLS, harden the listener, or stop bots from scanning 3306 the moment you open it.

A developer asks to connect MySQL Workbench from their laptop. The shortest path on cPanel is to add their IP under Remote MySQL and call it done. What that does in MySQL terms is create acmecorp_app@203.0.113.42 and grant it the same privileges already on acmecorp_app@localhost. What it does not do is bind MySQL to the public interface, add TLS, throttle bad logins, or stop scanners from probing 3306 with root and admin the moment the listener is reachable. Opening Remote MySQL without the supporting work is the most common reason cPanel hosts end up in fail2ban logs as the source of brute force noise.

What’s happening

bind-address in /etc/my.cnf controls which interface MySQL listens on. cPanel installs default to bind-address = 127.0.0.1, meaning Remote MySQL grants exist but the listener is unreachable. The Remote MySQL UI does not change bind-address — it only writes the allowlist. So the first time someone asks for remote access, they file a ticket that says “I added my IP but it still won’t connect.” A senior admin then opens bind-address to 0.0.0.0, and now MySQL is on the public internet for every account on the host, not just the one that asked.

Worse, mysql.user allows wildcard host entries. A grant for acmecorp_app@% (which cPanel will write if you put % in the Remote MySQL field) is functionally equivalent to “any IP on earth can try this username.” Combined with a weak password and 3306 open to the world, this is a credential stuffing target.

How to verify

ss -tlnp | grep 3306
grep bind-address /etc/my.cnf
mysql -e "SELECT User, Host FROM mysql.user WHERE Host NOT IN ('localhost','127.0.0.1','::1')"
firewall-cmd --list-rich-rules | grep 3306
csf -l | grep 3306

The first two show whether MySQL is even listening publicly. The third lists every account-host pair that can hit it. The last two confirm that your firewall — CSF on most cPanel hosts — actually restricts which sources can reach 3306, not just which credentials are allowed.

The fix

  1. Bind to a specific interface, not 0.0.0.0. If remote access is needed for one developer, bind MySQL to the public interface and let CSF restrict the source. If remote access is needed for an internal app server, bind to the private interface only.
  2. Add explicit firewall rules before any GRANT. In /etc/csf/csf.allow: tcp|in|d=3306|s=203.0.113.42. Reload CSF. The firewall enforces “who can knock”; the grants enforce “who can enter.” Both are required.
  3. Never grant 'user'@'%'. Always list explicit source IPs. If the developer’s IP is dynamic, give them a VPN or SSH tunnel to localhost, not a wildcard grant.
  4. Require TLS on remote logins: ALTER USER 'acmecorp_app'@'203.0.113.42' REQUIRE SSL forces the client to negotiate TLS. cPanel sets up MySQL TLS by default on recent builds, but the requirement is per-user — without REQUIRE SSL, the client may connect cleartext.
  5. Watch the auth log: tail -f /var/log/mysqld.log for “Access denied” bursts. Pipe to fail2ban with a MySQL jail if you see them. Reconsider whether remote MySQL is really necessary — SSH tunnel from the laptop is one more keystroke and keeps the listener off the public internet entirely.

For environments where remote database access is unavoidable and needs to stay sane across many cPanel accounts, Stack Harbor’s environment management team builds the bind-address, CSF, and TLS posture together and reviews the user-host table on each onboarding.