Introduction to MySQL
Comprehensive introduction to MySQL — what it is, how it works, the client/server architecture, storage engines (InnoDB, MyISAM, MEMORY), MySQL vs MariaDB vs PostgreSQL, the history from 1995 to MySQL 8.0, and why it powers most of the web. Includes the important note that MySQL doesn't actually use Oracle PL/SQL.
MySQL is the world's most widely deployed open-source relational database management system (RDBMS). It stores data in tables, lets applications query and modify that data with SQL, and handles concurrent access from many connections simultaneously. It's the database that powers an enormous portion of the web — most LAMP-stack sites, WordPress installations, and countless line-of-business applications run on it.
MySQL is open-source under the GNU GPL license, with a commercial license also available from Oracle Corporation, which has owned and developed it since acquiring Sun Microsystems in 2010. Its closest sibling — and source-compatible drop-in replacement — is MariaDB, a community fork started by MySQL's original creators after the Oracle acquisition.
A database is an organized collection of structured information — typically stored on disk and managed by a database server. The server lets users and applications:
- Store data persistently in tables made of rows and columns
- Query that data with SQL — fetching, filtering, joining, summarizing
- Modify it safely under concurrent access using transactions
- Constrain it through types, keys, and integrity rules so bad data can't get in
- Index it for fast lookups on large tables
MySQL is a relational database — the relational model, introduced by E.F. Codd in 1970, organizes data into relations (tables) with formal rules for joining and querying them. Other major relational databases include PostgreSQL, Microsoft SQL Server, Oracle Database, and SQLite.
| Year | Milestone |
|---|---|
| 1995 | First release by Michael "Monty" Widenius and David Axmark at MySQL AB (Sweden) |
| 2008 | Sun Microsystems acquires MySQL AB for $1 billion |
| 2009 | MariaDB forked by Monty Widenius after Oracle's acquisition of Sun is announced |
| 2010 | Oracle Corporation acquires Sun (and with it, MySQL) |
| 2018 | MySQL 8.0 — major rewrite: window functions, CTEs, JSON improvements, transactional data dictionary |
| Today | MySQL 8.0+ powers WordPress, Drupal, and countless web applications worldwide |
MySQL follows a client/server model. The MySQL server (the mysqld process) runs as a background service, listening for connections on TCP port 3306 by default. Clients — applications, scripts, or interactive tools — connect, send SQL statements over the network, and receive result sets back.
The flow:
- A client opens a TCP connection to the server (port 3306) and authenticates.
- It sends a SQL statement — say,
SELECT * FROM customers WHERE city = 'Chennai'; - The server parses the SQL into an internal tree, the optimizer picks an execution plan, the executor runs it, and the matching storage engine reads the rows from disk.
- The server streams the result rows back over the connection.
- The client uses or displays the rows; the connection stays open for more statements.
One of MySQL's distinctive features is pluggable storage engines — the part of the server that actually reads and writes table data on disk. Different engines have different feature trade-offs, and you can mix engines within a single database.
| Engine | Transactions | Row locking | Foreign keys | Best for |
|---|---|---|---|---|
| InnoDB (default) | Yes (ACID) | Yes | Yes | Almost everything — the modern default since 5.5 |
| MyISAM | No | No (table-level only) | No | Read-heavy legacy workloads; rarely used for new code |
| MEMORY | No | No | No | Temporary scratch tables held in RAM |
| ARCHIVE | No | No | No | Append-only logs you want compressed |
| CSV | No | No | No | Data exchange with spreadsheets |
As an RDBMS, MySQL gives you:
- Tables, rows, columns, indexes — the relational model.
- Referential integrity — foreign keys (with InnoDB) prevent orphan child rows.
- Transactions — wrap multiple statements in
BEGIN ... COMMIT/ROLLBACKfor atomic, all-or-nothing changes. - Standard SQL with MySQL extensions — joins, subqueries, window functions (8.0+), CTEs (8.0+), JSON support (5.7+).
- Stored programs — procedures, functions, triggers, events, views.
- Replication — primary-replica setups for read scale-out and high availability.
- Authentication and access control — fine-grained
GRANT/REVOKEpermissions. - Multiple storage engines per database (see above).
Several common ways to issue commands:
| Tool | What it is |
|---|---|
mysql CLI | The command-line client that ships with MySQL — simple, scriptable, the lowest-common-denominator tool |
| MySQL Workbench | Free GUI from Oracle — query editor, schema designer, server admin |
| DBeaver, HeidiSQL, Sequel Pro | Third-party GUI clients with broader feature sets |
| phpMyAdmin | Web-based admin UI bundled with most LAMP-stack hosting |
| Application drivers | Language-native libraries — mysqli/PDO in PHP, mysql-connector-python, mysql2 for Node.js, JDBC for Java, etc. |
Throughout this tutorial, code examples are written assuming you'll run them in the mysql CLI or Workbench — but they work the same way through any client.
Open a terminal, start the mysql client, and run two simple introspection commands:
The four databases — information_schema, mysql, performance_schema, sys — are MySQL's own metadata and system tables. You'll typically CREATE DATABASE myapp; for your own work.
- Free and open-source — no licensing cost; commercial license available if needed.
- Mature and stable — three decades of battle-testing in production, from tiny blogs to global-scale platforms.
- Easy to install and operate — single binary, sensible defaults, runs on any modern OS.
- Fast for typical workloads — InnoDB handles mixed read/write traffic well; MEMORY engine handles ephemeral hot data.
- Cross-platform — Linux, Windows, macOS, BSDs.
- Standard SQL with practical extensions — most code transfers with minimal changes from other relational databases.
- Huge ecosystem — libraries in every language, ORMs, monitoring tools, hosted offerings (RDS, Aurora, Cloud SQL, PlanetScale, etc.).
- Excellent documentation — dev.mysql.com/doc is comprehensive and free.
- Scales — modern MySQL handles billions of rows per table; many of the world's largest websites run on it.
| System | How it relates to MySQL |
|---|---|
| MariaDB | Community fork started after Oracle acquired MySQL — mostly compatible, drop-in replaceable for many use cases. Some features have diverged in 8.0+. |
| PostgreSQL | Independent open-source RDBMS — historically richer in standard-SQL features, advanced types, extensibility. Different syntax for some things. |
| SQLite | Embedded — runs in your application's process, not as a server. Fine for small/single-user apps; no concurrency for writes. |
| Microsoft SQL Server | Commercial, Microsoft's flagship RDBMS. T-SQL dialect (covered in our T-SQL tutorial section). Enterprise-focused. |
| Oracle Database | Commercial, Oracle's flagship enterprise RDBMS. PL/SQL dialect (covered in our Oracle PL/SQL section). |
The pages that follow build up MySQL knowledge from the ground:
- Data Types — what you can store in columns: integers, decimals, dates, strings, JSON, and more
- (After this section) Variables, control flow, stored procedures, functions, triggers, cursors, and error handling — the procedural side of MySQL
- MySQL is the world's most widely deployed open-source relational database, owned by Oracle since 2010, with the MariaDB fork as a close community-driven sibling.
- It uses a client/server architecture: applications connect over TCP/3306, send SQL, and receive result sets back.
- The MySQL server (
mysqld) parses, optimizes, executes SQL, and reads/writes data via pluggable storage engines. Use InnoDB — it's the default and the only one that supports transactions and foreign keys. - MySQL's procedural language is not Oracle PL/SQL — it's MySQL's own stored-program syntax. Similar in spirit, different in detail.
- You interact with MySQL through the
mysqlCLI, GUI tools (Workbench, DBeaver), or language drivers (mysqli/PDO,mysql-connector-python, JDBC, etc.). - It's free, fast, well-documented, and battle-tested — the safe choice for most relational-data workloads.