1. Ports
  2. Port 3306

Port 3306 is the default port for the MySQL database protocol. When your application connects to a MySQL server, when WordPress retrieves a blog post, when a web application authenticates a user, the conversation happens here. This is the port that made the dynamic web possible.

What MySQL Does

MySQL is a relational database management system. It stores data in tables with rows and columns, enforces relationships between them, and speaks SQL, the lingua franca of structured data. When you fill out a form on a website and your information gets saved somewhere, there's a good chance it lands in a MySQL database.

The MySQL protocol on port 3306 handles connection establishment, authentication, query transmission, and result delivery. It's a binary protocol, meaning client and server exchange structured packets of data rather than human-readable text. Each packet can be up to 16MB. Larger payloads get chunked.1

When a client connects, the server initiates a handshake. It sends a greeting packet containing its version, a random authentication challenge, and its capabilities. The client responds with credentials. If everything checks out, the conversation begins.2

The Key Insight

MySQL succeeded because it was good enough, fast enough, and free. In an era when Oracle cost tens of thousands of dollars per CPU, MySQL cost nothing. It wasn't the most feature-complete database. It wasn't the most standards-compliant. But it started instantly, ran on cheap hardware, and handled web workloads well.

The MyISAM storage engine, MySQL's original default, prioritized speed over safety. It didn't support transactions. It could lose data in a crash. But for read-heavy web applications serving mostly static content with occasional writes, it was perfect. The philosophy was pragmatic: most web pages are reads, most reads don't need ACID guarantees, so optimize for the common case.3

The LAMP Stack Revolution

Port 3306 became famous as part of the LAMP stack: Linux, Apache, MySQL, and PHP. All four components emerged in 1995, though the acronym came later. O'Reilly Media and MySQL AB popularized the term.4

This stack democratized web development. Before LAMP, building a dynamic website meant expensive commercial software, specialized knowledge, and significant capital. After LAMP, a college student with a $20/month shared hosting account could build applications that scaled to millions of users.

Some of the biggest websites in the world started on LAMP. Facebook ran on it. Wikipedia runs on it. WordPress, which powers over 40% of all websites, is built on it.5 Every time you read a blog post on a WordPress site, port 3306 is involved.

The Story Behind Port 3306

MySQL was created by Michael "Monty" Widenius and David Axmark. Development began in 1994, with the first release on May 23, 1995.6

The name comes from Widenius's daughter, My. Her name plus SQL. Simple as that. Widenius has three children: My, Max, and Maria. MySQL, MaxDB, and eventually MariaDB. This man's family tree reads like a database comparison chart.7

The specific choice of port 3306 is lost to history. Unlike well-known ports with documented rationale, 3306 appears to have been simply an available number in the registered port range when MySQL AB requested it from IANA. Sometimes the most consequential decisions are the least documented.

The Acquisition Drama

MySQL AB, the Swedish company behind MySQL, was acquired by Sun Microsystems in January 2008 for approximately $1 billion.8 Sun saw MySQL as central to their open-source strategy.

Then Oracle acquired Sun in January 2010 for $7.4 billion. The European Commission investigated, concerned about Oracle, a major commercial database vendor, controlling MySQL. Widenius launched a "Save MySQL" campaign, gathering 50,000 signatures.9

The deal went through anyway. On the day Oracle announced the Sun purchase, Widenius forked MySQL into MariaDB, named after his daughter Maria. He took a significant portion of the MySQL developer community with him.10

The fork created an interesting split. MariaDB aims for MySQL compatibility while adding features Oracle won't. Many Linux distributions now ship MariaDB as their default "MySQL" implementation. The irony: Oracle's acquisition, intended to consolidate database market share, inadvertently spawned a competitor.

How the Protocol Works

The MySQL protocol is binary, not text-based. Communication flows in packets with a simple structure: a 3-byte length field, a 1-byte sequence ID, and then the payload.11

Connection Phase:

  1. Server sends Protocol::Handshake with version info and authentication challenge
  2. Client optionally requests SSL/TLS upgrade
  3. Client sends Protocol::HandshakeResponse with credentials
  4. Server validates and either accepts or rejects

Command Phase:

Once authenticated, the client sends commands (queries, prepared statements, administrative commands) and the server responds with result sets, OK packets, or error packets.

The protocol has evolved over decades. MySQL 4.0 used simple password authentication. MySQL 4.1 introduced mysql_native_password with challenge-response. MySQL 8.0 made caching_sha2_password the default, requiring either TLS or RSA key exchange for secure password transmission.12

There's no RFC for the MySQL protocol. It's documented, but informally. The server itself is the reference implementation. This reflects MySQL's pragmatic origins: ship working software first, document later.13

Security Considerations

Port 3306 should almost never be exposed to the public Internet. A database is the crown jewels. Exposing it directly invites disaster.

And yet, researchers found over 3.6 million MySQL servers publicly accessible on the Internet. More than half had no host-based access controls.14 This represents either misconfiguration or dangerous optimism.

Notable Vulnerabilities:

CVE-2012-2122 was memorably described as "tragically comedic." Due to a memcmp() implementation quirk on certain systems, an attacker could simply retry authentication about 300 times. On vulnerable systems, one in every 256 attempts would succeed regardless of password. The fix was trivial, but the window of exposure was significant.15

CVE-2016-6662 allowed remote root code execution through MySQL configuration file injection. An attacker who could execute SQL could potentially gain root access to the underlying server.16

Best Practices:

  • Never expose port 3306 to the Internet directly
  • Use strong, unique passwords for all MySQL accounts
  • Implement host-based access controls (bind to localhost or specific IPs)
  • Use SSL/TLS for all connections, especially over networks
  • Keep MySQL updated; security patches matter
  • Use a VPN or SSH tunnel for remote administration

Port 33060: The New Protocol

MySQL 5.7.12 introduced the X Protocol on port 33060. It uses Google Protocol Buffers for message encoding, supports asynchronous operations, and enables the MySQL Document Store for JSON data.17

The X Protocol represents MySQL's attempt to modernize beyond its 1990s wire format. It's optional and complementary. Port 3306 remains the classic protocol's home.

Current Usage and Relevance

As of 2025, over 189,751 companies use MySQL.18 It consistently ranks among the top three database management systems globally, alongside Oracle and Microsoft SQL Server.19

The cloud database MySQL market is estimated at $15 billion with 15% annual growth projected through 2033. Every major cloud provider, including AWS, Google Cloud, Azure, and Alibaba Cloud, offers managed MySQL services.20

MySQL's competitors include PostgreSQL (its most direct open-source rival), MariaDB (its fork sibling), and the NoSQL databases that emerged in the 2010s. But MySQL endures. Legacy systems run on it. WordPress runs on it. Developers learn SQL on it.

PortServiceRelationship
33060MySQL X ProtocolModern MySQL protocol for async and document store
5432PostgreSQLPrimary open-source competitor
3307MySQL ClusterAlternative MySQL port for cluster management
1433Microsoft SQL ServerCommercial RDBMS alternative
1521OracleCommercial RDBMS alternative

Frequently Asked Questions

Was this page helpful?

😔
🤨
😃