Port 3306: MySQL / MariaDB

Port 3306 (TCP) is used by MySQL / MariaDB. Default MySQL and MariaDB server port. Bind to localhost unless remote access is needed.

3306Port
TCPProtocol
mysqlIANA service name
DatabasesCategory

Port range

3306 is a registered port (range 1024–49151). Any user can bind to it; IANA records which service registered the number.

Security

Port 3306 should not be reachable from the public internet. Restrict it to trusted networks or a VPN, and scan your public IP to confirm it is closed.

Open port 3306 in a firewall

ufw         sudo ufw allow 3306/tcp
iptables    sudo iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
firewalld   sudo firewall-cmd --permanent --add-port=3306/tcp
Windows     New-NetFirewallRule -DisplayName "MySQL / MariaDB 3306" -Direction Inbound -Protocol TCP -LocalPort 3306 -Action Allow

Check if port 3306 is open

nc -vz example.com 3306
Test-NetConnection example.com -Port 3306   # PowerShell
sudo ss -tulpn | grep ':3306 '   # what is listening locally (Linux)

Other databases ports

Frequently asked questions

What is port 3306 used for?
MySQL / MariaDB. Default MySQL and MariaDB server port. Bind to localhost unless remote access is needed.
Is port 3306 TCP or UDP?
TCP.