Is port 3306 (MySQL) exposed to the internet, and is that a ransom target?
Port 3306 is MySQL's default port, and a MySQL server listens on every interface unless restricted, so a public IP can make the database reachable from the whole internet. Port 3306 isn't on AdminKit's port-check tool's current nine-port list, so this guide shows how to confirm exposure manually — exposed MySQL root accounts have been a documented ransomware target.
By AdminKit team, Netbase JSC · Updated
Key takeaways
- MySQL’s
bind_addressdefaults to*, so a server with a public address listens on it unless someone narrows the setting. The X Protocol on port 33060 has the same default. - Every account is a user name plus a host pattern. Whether a stranger can even try a password depends on accounts such as
'root'@'%', not on the port alone. - The server sends its version string before authentication, and answers unknown hosts with error 1130, so a quick test from outside shows both reachability and which accounts are in play.
- The 2017 ransom campaign brute-forced root over the internet and replaced databases with a ransom table. A root login also opens file reads and writes on the host unless
secure_file_privis set. - Fix it with a private bind address for both ports, no remote root, a firewall rule, TLS required for remote clients, and a restricted file directory.
What does MySQL listen on by default?
MySQL’s server system variables reference gives bind_address a default value of *, which it defines as accepting TCP/IP connections on all of the host’s IPv4 interfaces and, where the host supports IPv6, all IPv6 interfaces. Unlike PostgreSQL or MongoDB, which start on loopback, a stock MySQL server is network-facing from its first start. If the host has a public address and nothing in front of it filters 3306, the server is reachable from anywhere.
There is a second listener that is easy to miss. Since MySQL 8.0 the X Plugin, which serves the X DevAPI and MySQL Shell’s document-store features, is on by default, and the X Plugin reference gives it mysqlx_port 33060 and mysqlx_bind_address *. IANA lists 3306 as mysql and 33060 as mysqlx. Narrowing bind_address does not narrow the X Protocol port; it has its own setting.
| Port | Protocol | Bind setting | Default bind |
|---|---|---|---|
| 3306 | Classic MySQL protocol | bind_address | *, all interfaces |
| 33060 | X Protocol (X Plugin) | mysqlx_bind_address | *, all interfaces |
Why do MySQL’s own defaults leave an opening?
A fresh MySQL installation is narrower than people assume, but not as narrow as they’d like. MySQL’s own reference manual states that installation “creates only a root@localhost superuser account that has all privileges and can do anything” — there’s no sprawl of default accounts to clean up, just the one. The catch is what happens to that single account: the manual is explicit that “if the root account has an empty password, your MySQL installation is unprotected: anyone can connect to the MySQL server as root without a password and be granted all privileges.” Whether that password gets set automatically depends entirely on how MySQL was installed, which means the same software can land in a secured or an unprotected state purely based on which install path was used, with no error or warning to flag the difference.
The manual lists the cases:
| Install method | What happens to the root password |
|---|---|
| Windows MSI installer and MySQL Configurator | You are offered the option of assigning one |
| macOS installer | A random password is generated and shown in a dialog |
| RPM packages | A random password is generated and written to the error log |
| Debian packages | You are offered the option of assigning one |
mysqld --initialize by hand | A random, already-expired password is written to the error log |
Containers add one more path. The official mysql image creates root with the password in MYSQL_ROOT_PASSWORD, but also accepts MYSQL_ALLOW_EMPTY_PASSWORD=yes, which its documentation warns leaves the instance completely unprotected and gives anyone superuser access.
The localhost part of root@localhost is what keeps a passwordless root off the network: MySQL accounts are a user name plus a host pattern, and a connection from 198.51.100.7 cannot use an account defined for localhost. The risk grows when someone creates 'root'@'%' or another wildcard-host account to let a remote tool connect, because % matches every address on the internet.
What does a MySQL server tell a stranger before login?
More than most databases. Under the classic MySQL wire protocol the server speaks first: the initial handshake packet carries the protocol version, a human-readable server version string, a connection ID and the authentication plugin’s challenge, all before the client has sent a byte. Anyone who can reach the port learns the exact MySQL or MariaDB release, which is enough to look it up against published advisories.
If no account matches the caller’s host at all, the server sends an error instead of a handshake. The server error reference lists it as 1130, “Host ‘%s’ is not allowed to connect to this MySQL server”. That is a useful signal in a self-test: 1130 means no wildcard account covers your address, while a handshake followed by error 1045, “Access denied for user”, means an account matched and passwords can be tried.
MySQL’s built-in host blocking does not help much against password guessing. max_connect_errors, default 100, blocks a host after that many successive connection requests are interrupted without a successful connection. A cleanly failed password attempt is a completed exchange, not an interrupted one, so it is not what this counter is designed to stop.
Has an exposed MySQL actually been attacked?
This gap has already been exploited at scale, and the timeline is well documented. In February 2017, after a wave of ransom attacks had already hit tens of thousands of exposed MongoDB servers, BleepingComputer reported that the same pattern moved to MySQL: attackers “attempted to brute-force their way into MySQL root accounts,” and once in, deleted the database’s contents and replaced them with a table demanding 0.2 Bitcoin, directing victims to “contact this email with your IP or database name to recover your database.” The campaign ran for roughly 30 hours and, per the researchers who tracked it, traced back to a single source IP — a reminder that this kind of attack doesn’t require a sophisticated operation, only an internet-reachable database with a weak or absent root password.
A root login reaches past the data as well. The FILE privilege, which root holds, lets SELECT ... INTO OUTFILE, LOAD DATA and LOAD_FILE() write and read files on the database host with the server’s own operating-system permissions. The secure_file_priv variable limits those operations to one directory; the reference manual says that if it is empty, it has no effect, and calls that not a secure setting.
How do you check your own exposure?
AdminKit’s open ports check checks a fixed nine-port list, and port 3306 isn’t on it — confirm your current public IP first with what is my IP, then test the port manually from a machine outside your network:
nc -vz -w 3 203.0.113.5 3306
nc -vz -w 3 203.0.113.5 33060
A connection that succeeds means the database is reachable from the internet; “connection refused” or a timeout means it’s closed or filtered. A reachable port 3306 isn’t automatically a breach, but it does mean your root account’s password, or lack of one, is the only thing standing between your data and the exact scenario BleepingComputer documented.
The AdminKit check runs against the public address of the browser that starts it, so it describes the connection you are on. A MySQL server at a hosting provider has to be tested from outside against its own address, the way shown here.
To see what the server says to a stranger, read the first bytes of the greeting, then try a login with an account name you do not use:
$ nc -w 3 203.0.113.5 3306 | head -c 80 | strings
$ mysql -h 203.0.113.5 -P 3306 -u probe -p --connect-timeout=5
Example results (illustrative; documentation addresses, text varies by version):
| Result | What it means |
|---|---|
A version string such as 8.4.x in the greeting | The server is reachable and has told you its release. |
ERROR 1130 (HY000): Host '198.51.100.7' is not allowed to connect | Reachable, but no account matches your address. Close the port anyway. |
ERROR 1045 (28000): Access denied for user 'probe'@'198.51.100.7' | Reachable, and a wildcard-host account let the login proceed. Passwords can be guessed. |
ERROR 3159 (HY000): Connections using insecure transport are prohibited | TLS is required. Good, but the port is still open. |
ERROR 2003 (HY000): Can't connect to MySQL server | Nothing reachable on 3306 from where you tested. |
How do you confirm the listener on your own host?
On the server, check the sockets and then ask MySQL which settings and accounts it is actually running with:
$ ss -ltnp | grep -E ':(3306|33060) '
LISTEN 0 151 *:3306 *:* users:(("mysqld",pid=1033,fd=24))
LISTEN 0 70 *:33060 *:* users:(("mysqld",pid=1033,fd=21))
mysql> SELECT @@bind_address, @@mysqlx_bind_address, @@require_secure_transport, @@secure_file_priv;
mysql> SELECT user, host, plugin FROM mysql.user WHERE host NOT IN ('localhost', '127.0.0.1', '::1');
The ss lines are an example of the default: both ports on every interface. The second query lists every account that can log in from somewhere other than the server itself; each row with % in the host column is an account the whole internet can try once the port is open.
How do you fix an exposed MySQL server?
- Confirm the root account has a strong, unique password — don’t assume your install method set one, since MySQL’s own documentation notes this varies by installer.
- Bind
mysqldto a private or loopback address in its configuration instead of listening on every interface, so a public IP on the host doesn’t automatically make the database reachable. - Do the same for the X Protocol port with
mysqlx_bind_address, or turn the X Plugin off withmysqlx=0if nothing uses it, as the X Plugin documentation describes. - Add a firewall rule restricting port 3306 to the specific application servers that need it, rather than relying on the database’s own authentication as the only barrier.
- Remove any additional accounts with blank passwords or overly broad host wildcards, since the 2017 campaign’s entry point was exactly this kind of leftover default.
- Turn on
require_secure_transportso remote clients must use TLS, and setsecure_file_privto a dedicated directory. - Move remaining accounts to
caching_sha2_password; MySQL 8.4 no longer enables the deprecatedmysql_native_passwordplugin by default. - If remote database access is genuinely needed, put it behind a VPN or an SSH tunnel rather than a direct port forward, so the authentication step isn’t the only thing standing between port 3306 and the open internet.
A [mysqld] block that applies those settings for a server reached only from one private application network:
[mysqld]
bind_address = 10.0.2.50
mysqlx_bind_address = 127.0.0.1
require_secure_transport = ON
secure_file_priv = /var/lib/mysql-files
None of this requires giving up remote database access entirely — it requires making sure a reachable port 3306 always sits behind a real password and, ideally, a second layer of network-level restriction, rather than depending on the install step having quietly done that for you.
The same exposed-database pattern BleepingComputer documented for MySQL also applies to PostgreSQL and to Redis, where a missing password turns a reachable port into a direct line to the data behind it.
Which servers may you test with these checks?
Every check this page links to is for assets you own or are explicitly authorized to test. Never scan, probe, or attempt to connect to a network or device you don’t control — AdminKit’s active checks only ever run against the IP making the request or an asset you’ve verified ownership of. See our Disclaimer and Acceptable Use Policy for the full terms.
MySQL’s wire protocol is one entry in AdminKit’s broader machine protocols cluster, which covers the network services and device-management protocols that routinely turn up exposed on servers, routers and other machine-to-machine endpoints.
This guide is general information, not a security audit of your specific network — see our disclaimer for what AdminKit's guidance does and does not commit to.
Frequently asked questions
Does a fresh MySQL install ship insecure by default?
MySQL's own documentation says installation creates only a single root@localhost superuser account, and whether it gets a real password depends entirely on the install method — some installers set one automatically, others leave it to the administrator to run the securing steps themselves. The network side is open by default: bind_address defaults to *, every IPv4 and IPv6 interface.
What happens if that root account is left with an empty password?
MySQL's documentation states it plainly: with an empty root password, "your MySQL installation is unprotected: anyone can connect to the MySQL server as root without a password and be granted all privileges" — combined with a reachable port 3306, that's a direct, unauthenticated path to the entire database.
Has this actually been exploited, or is it theoretical?
Documented, not theoretical — in February 2017, attackers ran an automated campaign that brute-forced MySQL root accounts, wiped the contents of hundreds of internet-reachable databases, and left a Bitcoin ransom note in their place, following the same pattern that had already hit exposed MongoDB servers weeks earlier.
Does AdminKit's port-check tool scan port 3306?
No. The tool checks a fixed list of nine specific TCP ports (23, 554, 1883, 8883, 502, 7547, 80, 443, 8080) chosen for how often they turn up misconfigured on home and small-office devices. 3306 and MySQL's second port, 33060, aren't on that list, so confirm your own exposure with the manual check below.
What's the fastest fix if my own port 3306 is reachable and shouldn't be?
Set a strong root password immediately if one isn't already set, bind MySQL to a private or loopback interface instead of all interfaces, and add a firewall rule restricting 3306 to only the application servers that need it.
Sources
- MySQL Reference Manual — Securing the Initial MySQL Account (default accounts, empty-password risk)
- MySQL Reference Manual — Server System Variables (bind_address, secure_file_priv, max_connect_errors)
- MySQL Reference Manual — X Plugin options and system variables (mysqlx_port, mysqlx_bind_address)
- MySQL Reference Manual — Disabling X Plugin
- MySQL Reference Manual — What Is New in MySQL 8.4 (mysql_native_password off by default)
- MySQL Server Error Message Reference (1045, 1130, 3159)
- MySQL Source Code Documentation — Protocol::HandshakeV10
- Docker Official Image — mysql (MYSQL_ALLOW_EMPTY_PASSWORD)
- IANA Service Name and Transport Protocol Port Number Registry
- BleepingComputer — Database Ransom Attacks Have Now Hit MySQL Servers (Feb 2017)
Want AdminKit to watch this for you?
Free checks tell you the state today. Protective DNS and monitoring tell you when it changes.
Talk to an expert
Huy Nguyen (David), Founder & CEO, Netbase JSC
Ask whether this fix applies to your setup, or get a second pair of eyes on your DNS and mail records.