localhost:3306

Port 3306 is MySQL territory. Every MySQL server listens here by default. Unlike web ports, you don't open this in a browser — you connect with a MySQL client, phpMyAdmin, or your application's database driver.

Connect to MySQL

Command Line

# Local connection
mysql -u root -p

# Specify host and port
mysql -h localhost -P 3306 -u root -p

# Connect to remote server
mysql -h 192.168.1.100 -P 3306 -u myuser -p

Connection String

# PHP (PDO)
$pdo = new PDO('mysql:host=localhost;port=3306;dbname=mydb', 'user', 'pass');

# Node.js
mysql.createConnection({
  host: 'localhost',
  port: 3306,
  user: 'root',
  password: 'password',
  database: 'mydb'
});

# Python
connection = mysql.connector.connect(
  host='localhost',
  port=3306,
  user='root',
  password='password'
)

Check if MySQL is Running

# Linux
sudo systemctl status mysql

# Mac (Homebrew)
brew services list | grep mysql

# Check port
netstat -an | grep 3306

Can't Connect?

ErrorSolution
Connection refusedMySQL not running. Start the service.
Access deniedWrong username/password or missing privileges
Host not allowedUser needs GRANT for your host
Socket errorTry 127.0.0.1 instead of localhost

Change MySQL Port

# my.cnf or my.ini
[mysqld]
port = 3307

# Then restart MySQL

MySQL vs MariaDB

MariaDB (MySQL fork) also uses port 3306 by default. They're compatible — same port, same protocol.

Related Ports

PortDatabase
5432PostgreSQL
27017MongoDB
6379Redis
1433SQL Server