Toolman

What port does MySQL use?

MySQL uses port 3306 over TCP.

PortProtocolNameWhat it is for
3306TCPMySQL / MariaDBThe default MySQL and MariaDB port.

Exposing it

Bind to 127.0.0.1 unless a remote application genuinely needs it, and then restrict by source address. Internet-exposed MySQL is scanned constantly.

Checking it is listening

sudo lsof -i :3306          # macOS, Linux
netstat -ano | findstr :3306   # Windows
nc -zv host 3306               # from elsewhere

An "address already in use" error on a port nothing appears to be holding usually means the socket is in TIME_WAIT rather than that a process has it — the ports reference covers that and the ephemeral range.

Frequently asked questions

What port does MySQL use?

MySQL uses port 3306 over TCP. The default MySQL and MariaDB port.

Is port 3306 safe to expose to the internet?

Bind to 127.0.0.1 unless a remote application genuinely needs it, and then restrict by source address. Internet-exposed MySQL is scanned constantly.

How do I check whether MySQL is listening?

sudo lsof -i :3306 on macOS or Linux, netstat -ano | findstr :3306 on Windows. From another machine, nc -zv host 3306 says whether anything answers.

Other services

Port 3306 in full · Every service · All port numbers