Common attacks and weaknesses
- Brute force against database accounts, including root.
- Data theft and ransom notes left in wiped databases.
- Unencrypted connections when TLS is not required.
MySQL and MariaDB database server.
The application sends a SQL query to the MySQL / MariaDB server on port 3306, which returns rows from its tables. Encryption is optional: traffic is only protected if TLS is enabled on the server and the client.
| Service | Port | Transport | Description | Reference | Updated |
|---|---|---|---|---|---|
| mysql | 3306 | TCP, UDP | MySQL | - | - |
// source: IANA service name and port number registry
Linux
sudo ss -ltnup 'sport = :3306' # process listening on 3306
sudo lsof -nP -i :3306macOS
sudo lsof -nP -i :3306
Windows (PowerShell)
Get-NetTCPConnection -LocalPort 3306 -State Listen | Select LocalAddress, OwningProcess Get-NetUDPEndpoint -LocalPort 3306 netstat -ano | findstr :3306
From another machine
nmap -p 3306 -sV <host> sudo nmap -sU -p 3306 <host> nc -zv <host> 3306
Block it in the firewall
sudo ufw deny 3306/tcp # Linux (ufw) New-NetFirewallRule -DisplayName "Block 3306" -Direction Inbound -LocalPort 3306 -Protocol TCP -Action Block # Windows
MySQL and MariaDB database server.
Port 3306 is registered for TCP and UDP. In practice the service mostly uses TCP.
It is rated 8/10 (high) when exposed to the Internet. Brute force against database accounts, including root. Bind to 127.0.0.1 or a private network, never 0.0.0.0 on the Internet.
On Linux run "ss -ltnup 'sport = :3306'", on macOS "lsof -nP -i :3306", and on Windows "netstat -ano | findstr :3306" to see the local process. From another machine, "nmap -p 3306 <host>" shows whether it is reachable.