MySQL Intro MySQL · Intro

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.

📌 Note on terminology: Despite this site's "MySQL PL/SQL" label, MySQL doesn't actually use Oracle's PL/SQL. MySQL has its own procedural language for stored procedures, functions, and triggers — usually called "MySQL stored programs" or just "MySQL procedural SQL". The syntax is similar to standard SQL/PSM and resembles PL/SQL in spirit, but is its own thing.

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.

YearMilestone
1995First release by Michael "Monty" Widenius and David Axmark at MySQL AB (Sweden)
2008Sun Microsystems acquires MySQL AB for $1 billion
2009MariaDB forked by Monty Widenius after Oracle's acquisition of Sun is announced
2010Oracle Corporation acquires Sun (and with it, MySQL)
2018MySQL 8.0 — major rewrite: window functions, CTEs, JSON improvements, transactional data dictionary
TodayMySQL 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.

CLIENTS Web app (PHP, Node…) mysql CLI MySQL Workbench SQL over TCP :3306 mysqld parser · optimizer · executor storage engines InnoDB · MyISAM · Memory access control · replication data files .ibd · binlog DISK SERVER

The flow:

  1. A client opens a TCP connection to the server (port 3306) and authenticates.
  2. It sends a SQL statement — say, SELECT * FROM customers WHERE city = 'Chennai';
  3. 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.
  4. The server streams the result rows back over the connection.
  5. 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.

EngineTransactionsRow lockingForeign keysBest for
InnoDB (default)Yes (ACID)YesYesAlmost everything — the modern default since 5.5
MyISAMNoNo (table-level only)NoRead-heavy legacy workloads; rarely used for new code
MEMORYNoNoNoTemporary scratch tables held in RAM
ARCHIVENoNoNoAppend-only logs you want compressed
CSVNoNoNoData exchange with spreadsheets
💡 Use InnoDB for new tables. It's been the default storage engine since MySQL 5.5 (2010), supports transactions and foreign keys, and is the only engine that gives you ACID guarantees. The other engines exist for specific niches.

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 / ROLLBACK for 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 / REVOKE permissions.
  • Multiple storage engines per database (see above).

Several common ways to issue commands:

ToolWhat it is
mysql CLIThe command-line client that ships with MySQL — simple, scriptable, the lowest-common-denominator tool
MySQL WorkbenchFree GUI from Oracle — query editor, schema designer, server admin
DBeaver, HeidiSQL, Sequel ProThird-party GUI clients with broader feature sets
phpMyAdminWeb-based admin UI bundled with most LAMP-stack hosting
Application driversLanguage-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.

Example — Connect and Run a Query

Open a terminal, start the mysql client, and run two simple introspection commands:

OUTPUT
mysql — first look
vriddh@prod-01:~$mysql -u root -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Server version: 8.0.36 MySQL Community Server - GPL
mysql>SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 8.0.36 |
+-----------+
1 row in set (0.00 sec)
mysql>SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
mysql>

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 documentationdev.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.
SystemHow it relates to MySQL
MariaDBCommunity fork started after Oracle acquired MySQL — mostly compatible, drop-in replaceable for many use cases. Some features have diverged in 8.0+.
PostgreSQLIndependent open-source RDBMS — historically richer in standard-SQL features, advanced types, extensibility. Different syntax for some things.
SQLiteEmbedded — runs in your application's process, not as a server. Fine for small/single-user apps; no concurrency for writes.
Microsoft SQL ServerCommercial, Microsoft's flagship RDBMS. T-SQL dialect (covered in our T-SQL tutorial section). Enterprise-focused.
Oracle DatabaseCommercial, 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 mysql CLI, 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.