Port 3306 is the default MySQL and MariaDB database port. Production databases should never expose port 3306 to the public internet – connections should come only from localhost or through SSH tunneling. Most security breaches involving databases occur because port 3306 is accidentally exposed.
Port Number
3306
Protocol
TCP
Service
MySQL Database
Range
IANA Registered (1024–49151)
Test basic MySQL connectivity and authentication
mysql -h host -P 3306 -u root -p -e 'SELECT 1'Check MySQL server status (uptime, threads, queries)
mysqladmin -h localhost -P 3306 -u root -p statusVerify which process owns port 3306 and what address it binds to
ss -tnlp sport = :3306Detect MySQL version remotely (should fail if properly firewalled)
nmap -sV -p 3306 targetmysql -h localhost -P 3306 -u root -p
ssh -L 3306:localhost:3306 user@server
mysql -h 127.0.0.1 -P 3306MySQL was created by Michael Widenius at MySQL AB in 1995. Oracle acquired it via Sun Microsystems in 2010. MariaDB forked in 2009 as a community-driven alternative. Port 3306 was registered with IANA for MySQL. The X Protocol (port 33060) was added in MySQL 5.7 for document store operations.
MySQL vs MariaDB – same port?
Yes, both default to 3306 and use the same wire protocol. MariaDB is a drop-in replacement for MySQL up to version 10.x. They diverge on features (MariaDB has Aria engine, Oracle MySQL has Group Replication) but port and protocol remain compatible.
How do I allow remote MySQL access securely?
Never open port 3306 to the internet. Options: (1) SSH tunnel – ssh -L 3306:localhost:3306 user@dbserver, then connect to localhost:3306. (2) VPN – database on private subnet, connect via WireGuard/OpenVPN. (3) Cloud IAM – RDS IAM authentication with security group restricting to your VPC.