Database
Risk: High
Port 3306 β MySQL / MariaDB Database
Port 3306 is the default port for MySQL and MariaDB databases worldwide. Client libraries (mysql2, PDO, PyMySQL) default to this port for connections.
PORT NUMBER
3306
PROTOCOL
TCP
DEFAULT PROCESS
mysqld, mariadbd
FIREWALL TARGET
3306/tcp
Instant Terminal Fixes for Port 3306
macOS & Linux Terminal
1. Check who is listening on port 3306:
sudo ss -tulpn | grep 3306 || mysqladmin ping2. Kill process occupying port 3306 (EADDRINUSE fix):
sudo systemctl stop mysql || sudo kill -9 $(sudo lsof -t -i:3306)3. UFW Firewall Allow rule:
sudo ufw allow from 192.168.1.0/24 to any port 3306 proto tcpWindows PowerShell (Admin)
1. Check listening port:
Get-NetTCPConnection -LocalPort 33062. Force kill process on port 3306:
Stop-Service MySQL* -Force3. Docker Port Forwarding Mapping:
docker run -p 3306:3306 -e MYSQL_ROOT_PASSWORD=secret -d mysql:8Common Error Encountered
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1:3306' (111)
Security Advisory & Hardening
Ensure the root user cannot log in remotely (`bind-address = 127.0.0.1` in my.cnf). Use strong user passwords and disable LOAD DATA LOCAL INFILE.
Frequently Asked Questions
Port 3306 Questions & Answers
Common questions regarding default services, kill commands, and firewall configurations.
Port 3306 is commonly used for MySQL / MariaDB Database. Port 3306 is the default port for MySQL and MariaDB databases worldwide. Client libraries (mysql2, PDO, PyMySQL) default to this port for connections.