Port 3306: MySQL (MySQL and MariaDB database)
What port 3306 (TCP) does, the security risks of leaving it open, and how to secure and test it.
| Port | 3306 |
|---|---|
| Transport | TCP |
| Service | MySQL and MariaDB database (MySQL) |
| Encrypted | Optional (TLS) |
What is port 3306?
TCP 3306 is the default port for MySQL and MariaDB databases, used by many websites and applications.
Common uses
- Websites such as WordPress connecting to their database
Security risks
- Internet-exposed databases scanned and brute-forced
- Weak root passwords
- Data theft through SQL injection in the website
How to secure port 3306
- Bind MySQL to localhost or a private network only
- Use strong passwords and remove anonymous users
- Require TLS for remote connections
How to check if port 3306 is open
| Where | Command |
|---|---|
| Scan from another machine | nmap -p 3306 <host> |
| Windows (PowerShell) | Test-NetConnection <host> -Port 3306 |
| Linux (what is listening) | sudo ss -tulpn | grep :3306 |
| Windows (what is listening) | netstat -ano | findstr :3306 |
Only scan systems you own or have permission to test.
Example: block it at the internet edge (Cisco)
For a service that should stay inside your network, deny it on the internet-facing interface. Put the rule before any broader permit statements:
ip access-list extended INTERNET-IN
remark Block MySQL from the internet
deny tcp any any eq 3306
permit ip any any
!
interface GigabitEthernet0/0
ip access-group INTERNET-IN inIn a real network the final line would be your normal inbound policy, not "permit ip any any". Build and check rules with the ACL builder.
Related ports
Frequently asked questions
What is port 3306 used for?
Port 3306 (TCP) is used by MySQL and MariaDB database (MySQL). TCP 3306 is the default port for MySQL and MariaDB databases, used by many websites and applications.
Is it safe to open port 3306?
Only if the service needs to be reached and is configured securely. Bind MySQL to localhost or a private network only.
How do I check if port 3306 is open?
From another computer, run nmap -p 3306 followed by the host address. On the server itself, ss -tulpn on Linux or netstat -ano on Windows shows whether anything is listening on 3306.
Learn more: TCP, UDP and ports explained and firewall basics.