Migrate to RunxBuild and earn up to $50 in hosting credit on your first deposit.

Calculate your savings
unxBuild

MySQL Port: 3306 Default, Change, and Multi-Version Setup

Sean

Platform Writer

Jul 05, 2026
4 min read

MySQL default port is 3306, registered with IANA. The MySQL port reference documents all default ports. The team that uses non-standard ports for production has security-through-obscurity. The team that uses the default with proper firewall + auth has the right baseline.

MySQL Port: 3306 Default, Change, and Multi-Version Setup

Table of contents

The default port

MySQL’s IANA-registered port is 3306. Per the MySQL docs, this is the port the mysqld server listens on by default.

mysql -h localhost -P 3306 -u root -p

Change the port

Edit /etc/mysql/mysql.conf.d/mysqld.cnf (Ubuntu) or /etc/my.cnf (RHEL):

[mysqld]
port = 3307

Restart:

sudo systemctl restart mysql

The team that changes the port updates connection strings everywhere.

Verify port

sudo ss -tlnp | grep mysql

Shows the listening port. The team that verifies has confirmation the change worked.

Multiple MySQL versions on one host

Use different ports or named sockets:

# MySQL 8.0
[mysqld]
port = 3306
socket = /var/run/mysqld/mysql-8.sock

# MySQL 8.4
[mysqld]
port = 3307
socket = /var/run/mysqld/mysql-84.sock

The team that runs multiple versions has them coexisting on different ports/sockets.

Firewall

Open the new port:

sudo ufw allow 3307/tcp

The team that has a firewall has the right port open. The team that has 3306 closed at the firewall is unreachable from outside.

  • MySQL client: 3306.
  • MySQL X Protocol: 33060.
  • MySQL Admin Port: 33062.
  • MySQL Router: 6446 (read-write), 6447 (read-only).

The team that uses X Protocol has port 33060 open. The team that uses Router has 6446/6447.

FAQ

What’s the default port for MySQL?

3306 (IANA-registered).

Can I change the port without breaking apps?

Yes if you update connection strings. The team that uses config management (Ansible, Chef) has the port change propagated.

Why is 3306 the default?

IANA assigned it in the 1990s. Has stuck since.

Is MySQL’s port configurable per connection?

Yes - clients can connect to any port via -P 3307. The team that uses custom ports has clients configured correctly.

What’s the X Protocol port?

33060 (default). The team that uses X Protocol (MySQL Document Store, async) has 33060 open.

If you are sizing the infrastructure for the kind of project this post covers, the RunxBuild hosting calculator is the right place to model the line items. The compute, the memory, the storage, the bandwidth, the database - each one is a separate number, and the team’s mental model for the platform is the sum of those numbers. The RunxBuild dashboard is where the team sees the actual usage in one place.

Useful related references:

#mysql#port#config#dev-infra