Preparing your learning space...
25% through Getting Started tutorials
MySQL is the world's most popular open-source relational database management system (RDBMS). It uses SQL (Structured Query Language) to manage and query data stored in tables.
MySQL is an open-source Relational Database Management System (RDBMS) developed by Oracle Corporation. It is the "M" in the LAMP stack (Linux, Apache, MySQL, PHP/Python/Perl) — one of the most popular web development stacks in the world.
MySQL allows you to:
Unlike SQL (the language), MySQL is the software that understands and executes SQL commands.
-- This is MySQL running a SQL command
SELECT first_name, last_name FROM employees WHERE department = 'Engineering';
MySQL is known for its speed, reliability, and ease of use. It powers some of the largest websites and applications in the world.
MySQL has a rich history spanning three decades:
| Year | Milestone |
|---|---|
| 1979 | Michael "Monty" Widenius developed UNIREG, a database tool that laid the groundwork for MySQL |
| 1994 | Widenius and David Axmark began developing a new SQL-based database using UNIREG and mSQL |
| 1995 | The first internal release of MySQL appeared |
| 1996 | MySQL 3.11 — first public release under a custom license, available on Linux and Solaris |
| 2001 | MySQL 3.23 introduced InnoDB (transaction support) and MyISAM as the default engine |
| 2005 | MySQL 5.0 introduced views, stored procedures, triggers, and cursors |
| 2008 | Sun Microsystems acquired MySQL AB for $1 billion |
| 2010 | Oracle acquired Sun Microsystems (and MySQL) for $7.4 billion |
| 2013 | MySQL 5.6 improved performance, added NoSQL access via Memcached API |
| 2015 | MySQL 5.7 introduced JSON support, improved InnoDB performance |
| 2018 | MySQL 8.0 shipped with Window Functions, CTEs (Common Table Expressions), roles, and a new data dictionary |
| 2024 | MySQL 8.4 LTS released as the new long-term support version |
| 2025 | MySQL 9.x series continued improvements in performance, security, and replication |
The name story: MySQL is named after My (Michael Widenius's daughter) combined with SQL (Structured Query Language).
Market dominance — More than 50% of web applications use MySQL. It runs WordPress, Drupal, Joomla, and countless custom apps.
Industry standard — Companies like Meta (Facebook), Netflix, YouTube, Twitter, and Booking.com use MySQL at massive scale.
Job opportunities — MySQL skills are in demand across backend development, data analysis, DevOps, and database administration.
Free and open-source — No licensing cost. You can download, use, and modify it freely.
Huge ecosystem — Extensive documentation, millions of Stack Overflow answers, countless tools, and a massive community.
Scalable — Works equally well for a single-user app on your laptop and a multi-terabyte database serving millions of users.
Transferable SQL skills — Once you know MySQL, you can work with PostgreSQL, SQL Server, SQLite, and any other SQL database. The core language is the same.
Foundation for advanced topics — Data warehousing, big data tools (Spark, Hive), and ORMs (Object-Relational Mappers) all build on SQL concepts.
| Feature | Description |
|---|---|
| ACID Compliance | Transactions are Atomic, Consistent, Isolated, and Durable (when using InnoDB) |
| Replication | Master-slave, master-master, and group replication for high availability |
| Partitioning | Split large tables across multiple files for better performance |
| Full-text Search | Built-in full-text indexing and searching for text columns |
| Indexing | B-tree, Hash, Full-text, Spatial, and JSON indexes for fast lookups |
| Stored Procedures | Pre-compiled SQL code stored on the server |
| Triggers | Automatic actions when data is inserted, updated, or deleted |
| Views | Virtual tables based on the result of a stored query |
| Foreign Keys | Enforce referential integrity between related tables |
| JSON Support | Store, query, and index JSON data natively (since MySQL 5.7) |
| Window Functions | Perform calculations across related rows (since MySQL 8.0) |
| Common Table Expressions (CTEs) | Write recursive and non-recursive CTEs (since MySQL 8.0) |
| Advantage | Why it matters |
|---|---|
| Easy to learn | Simple installation, intuitive SQL syntax, gentle learning curve |
| Fast performance | Optimized for read-heavy workloads; handles millions of queries per second at scale |
| Reliable | Mature codebase with decades of production use; crash recovery via InnoDB |
| Cross-platform | Runs on Windows, Linux, macOS, and most Unix systems |
| Great tooling | MySQL Workbench (GUI), mysqldump (backup), mysqladmin (admin), and countless third-party tools |
| Replication built-in | Easy to set up master-slave replication for scaling reads or disaster recovery |
| Large community | Vast resources, tutorials, and experienced developers available online |
| Hosting everywhere | Every web host supports MySQL; cloud services offer managed MySQL (Amazon RDS, Google Cloud SQL, Azure Database) |
| Disadvantage | Why it matters |
|---|---|
| Limited advanced features | Lacks some PostgreSQL features like partial indexes, table inheritance, and advanced data types |
| Strict ACID only with InnoDB | The default storage engine for many years (MyISAM) did not support transactions or foreign keys |
| Less SQL standards compliance | MySQL deviates from the SQL standard in some areas (e.g., handling of GROUP BY) |
| Read locks on MyISAM | Reads block writes and writes block reads on MyISAM tables (a non-issue with InnoDB) |
| No full SQL standard support | Missing features like CHECK constraints (enforced only from MySQL 8.0.16), exclusion constraints |
| Performance under Oracle | Some debate about Oracle's commitment to open-source development pace |
| Complex licensing | The Oracle Standard Edition is expensive; the GPL license has restrictions for commercial redistribution |
MySQL uses a modular, client-server architecture:
┌─────────────────────────────────────────────────────┐
│ Client │
│ (mysql CLI, MySQL Workbench, App via connector) │
└──────────────────────────┬──────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────┐
│ Connection Management │
│ (Authentication, SSL/TLS, Thread Pool, Limits) │
└──────────────────────────┬──────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────┐
│ SQL Layer │
│ ┌──────────┐ ┌──────────┐ ┌───────────────────┐ │
│ │ Parser │ │ Optimizer│ │ Query Execution │ │
│ │(syntax │ │(cost- │ │ Engine (operators) │ │
│ │ check) │ │ based) │ │ │ │
│ └──────────┘ └──────────┘ └───────────────────┘ │
└──────────────────────────┬──────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────┐
│ Storage Engine Layer │
│ ┌──────────┐ ┌──────────┐ ┌──────┐ ┌──────────┐ │
│ │ InnoDB │ │ MyISAM │ │Memory│ │ Others │ │
│ │(default) │ │(legacy) │ │ │ │(CSV, etc)│ │
│ └──────────┘ └──────────┘ └──────┘ └──────────┘ │
└──────────────────────────┬──────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────┐
│ File System │
│ (Data files, Log files, Config files) │
└─────────────────────────────────────────────────────┘
Client Layer — Applications and tools connect to the MySQL server using the MySQL protocol (port 3306 by default).
Connection Management — Handles authentication, maintains connection pools, applies connection limits, and manages SSL/TLS encryption.
SQL Layer (also called the Server Layer):
Storage Engine Layer — MySQL's most distinctive feature. Storage engines are pluggable — you choose one per table:
File System — The actual data on disk: tablespace files (.ibd), undo logs, redo logs, binary logs, error logs, and configuration files (my.cnf or my.ini).
MySQL comes in several editions:
| Edition | License | Cost | Features |
|---|---|---|---|
| MySQL Community Server | GPL v2 | Free | Full-featured, all core functionality |
| MySQL Standard Edition | Commercial | Paid | Community + Oracle support, enterprise monitoring |
| MySQL Enterprise Edition | Commercial | Paid | Standard + advanced security, audit, backup, monitoring |
| MySQL Cluster CGE | Commercial | Paid | Enterprise + distributed clustering, real-time performance |
| MySQL HeatWave | Cloud service | Usage-based | Enterprise + in-memory query accelerator (HeatWave engine) |
The Community Edition is what most developers use. It includes everything needed for development and production — InnoDB, replication, partitioning, JSON, window functions, and all other core features.
The Enterprise Edition adds:
MySQL is used across virtually every industry:
| Use Case | Examples |
|---|---|
| Web applications | User accounts, sessions, content management, product catalogs |
| E-commerce | Inventory, orders, customer data, shopping carts, pricing |
| Content Management | WordPress (over 40% of all websites), Drupal, Joomla |
| Social media | User profiles, posts, likes, comments, friend relationships |
| Mobile apps | User data, push tokens, settings, message history |
| Banking & finance | Transaction logs, account data, ledgers, compliance records |
| Healthcare | Patient records, appointments, prescriptions, lab results |
| Analytics & reporting | Sales dashboards, KPI tracking, business intelligence |
| SaaS platforms | Multi-tenant data, billing records, usage metrics |
| IoT (Internet of Things) | Sensor readings, device metadata, event logs |
This is one of the most common points of confusion for beginners:
SQL → The LANGUAGE (standard, vendor-independent)
MySQL → A SOFTWARE that speaks the SQL language
| Aspect | SQL | MySQL |
|---|---|---|
| What it is | A standardized query language | A database management system (RDBMS) |
| Purpose | Define how to query and manipulate data | Implement the SQL language to store/retrieve data |
| Created by | ANSI/ISO standards bodies | MySQL AB (now Oracle) |
| Ownership | Public standard, no single owner | Oracle Corporation |
| Extensions | Defines the core syntax | Adds MySQL-specific features and functions |
| Examples | SELECT, INSERT, UPDATE | SHOW TABLES, DESCRIBE, EXPLAIN, storage engines |
SQL is to MySQL what English is to a person who speaks English. MySQL speaks SQL, but adds its own dialect, features, and extensions.
MySQL-specific extensions to SQL include:
SHOW DATABASES, SHOW TABLES, DESCRIBE table_nameEXPLAIN for query plan analysisAUTO_INCREMENT for automatic ID generationLIMIT clause (now adopted by other databases too)REPLACE INTO (insert or update)INSERT ... ON DUPLICATE KEY UPDATEMATCH ... AGAINSTLOAD DATA INFILE for bulk importsMariaDB is a fork of MySQL created by the original MySQL developers after Oracle's acquisition.
| Aspect | MySQL | MariaDB |
|---|---|---|
| Origin | Original, owned by Oracle | Fork of MySQL by Monty Widenius (original MySQL founder) |
| Year created | 1995 | 2009 |
| Licensing | Dual license (GPL / Commercial) | GPL v2 (fully open-source) |
| Development | Oracle Corporation | MariaDB Foundation (community-driven) |
| Compatibility | The reference standard | Drop-in replacement for MySQL in most cases |
| Storage engines | InnoDB (default), MyISAM, Memory, CSV, Archive | InnoDB + Aria, XtraDB, ColumnStore, Spider, Connect, many more |
| Performance | Excellent, heavily optimized | Comparable, often slightly faster in some benchmarks |
| New features | Enterprise-focused (HeatWave, Group Replication) | Community-focused (more storage engines, new features faster) |
| Security fixes | Prompt via Oracle | Quick via MariaDB foundation |
| Latest version | MySQL 9.x (2025) | MariaDB 11.x (2025) |
| Scenario | Choose |
|---|---|
| Learning SQL for the first time | Either — both are great |
| Deploying to a hosting provider | MySQL (wider hosting support) |
| Using specific MySQL Enterprise features | MySQL |
| Preferring fully open-source (no Oracle) | MariaDB |
| Wanting more storage engine options | MariaDB |
| Using WordPress or popular CMS | MySQL (more widely tested) |
Bottom line: MySQL and MariaDB are very similar. Skills transfer easily between them. If you're starting out, go with MySQL — it has the larger ecosystem, and you can switch later if needed.
| Aspect | MySQL | PostgreSQL |
|---|---|---|
| Type | Relational DBMS | Object-Relational DBMS |
| SQL compliance | Good, but not fully compliant | Excellent — more compliant with SQL standard |
| ACID | Yes (InnoDB) | Yes (always) |
| Storage engines | Pluggable (multiple engines) | Single engine (built-in) |
| Indexing | B-tree, Hash, Full-text, Spatial, JSON | B-tree, Hash, GiST, GIN, SP-GiST, BRIN, Bloom |
| JSON support | Good (native JSON type since 5.7) | Excellent (JSONB with indexing since 9.4) |
| Full-text search | Built-in (MyISAM/InnoDB) | Built-in (more advanced) |
| Concurrency | Good (row-level locking in InnoDB) | Excellent (MVCC, more isolation levels) |
| Replication | Master-slave, Group Replication | Streaming replication, logical replication |
| Performance (reads) | Very fast | Fast |
| Performance (writes) | Fast | Good (slightly slower on simple writes) |
| Complex queries | Good (improved in MySQL 8.0+) | Excellent (more optimization options) |
| Geospatial | Good (since MySQL 5.7/8.0) | Excellent (PostGIS — the gold standard) |
| Learning curve | Easy | Moderate |
| Community | Largest | Large and passionate |
| Hosting | Universal | Widely available |
| Aspect | MySQL | SQLite |
|---|---|---|
| Type | Client-server RDBMS | Embedded (serverless) database |
| Setup | Install server, connect via client | No setup — just include the library |
| Architecture | Separate server process | Runs inside your application |
| Storage | Files managed by server | Single file (.db or .sqlite) |
| Concurrency | Multiple concurrent writers | Single writer at a time |
| Scale | Gigabytes to terabytes | Kilobytes to gigabytes |
| Performance | Fast (network overhead) | Very fast (no network overhead) |
| Features | Full-featured (users, permissions, replication) | Minimal (no users, no replication) |
| Portability | Needs a server | Extremely portable (just a file) |
| Best for | Production web apps, enterprise | Mobile apps, prototypes, small tools, embedded systems |
| Replication | Built-in | Not available |
| User management | Yes | No (no users at all) |
| Backup | mysqldump, binary logs | Just copy the file |
Analogy: MySQL is like a professional restaurant kitchen (powerful, many cooks, needs setup). SQLite is like a pocket knife (always ready, simple, limited to small jobs).
MySQL is made up of several key components:
| Component | Description |
|---|---|
| mysqld | The MySQL server daemon — the core process that handles all database operations |
| mysql | The MySQL command-line client for connecting to the server |
| mysqladmin | Administrative tool (shutdown, status, create/drop databases) |
| mysqldump | Backup tool that exports databases to SQL files |
| mysqlcheck | Table maintenance (check, repair, optimize, analyze) |
| mysqlimport | Import data from text files into tables |
| mysqlshow | Display database, table, and column information |
| mysqlslap | Load emulation client for performance testing |
MySQL's pluggable storage engine architecture is one of its defining features:
| Engine | Transactions | Row Locking | Foreign Keys | Best For |
|---|---|---|---|---|
| InnoDB (default) | ✅ | ✅ | ✅ | General purpose, production workloads |
| MyISAM | ❌ | ❌ (table-level) | ❌ | Legacy apps, read-only data, full-text search |
| Memory (Heap) | ❌ | ✅ (table-level) | ❌ | Temporary tables, caching, lookup tables |
| CSV | ❌ | ❌ | ❌ | Data exchange with spreadsheets |
| Archive | ❌ | ❌ | ❌ | Log storage, historical data (high compression) |
| Blackhole | ❌ | ❌ | ❌ | Replication relay (accepts writes, discards data) |
| Federated | ❌ | ❌ | ❌ | Access remote MySQL tables locally |
| NDB (Cluster) | ✅ | ✅ | ✅ | Distributed clustering, high availability |
| File Type | Extension | Purpose |
|---|---|---|
| Tablespace files | .ibd | InnoDB table data and indexes |
| System tablespace | ibdata1 | InnoDB system data (undo logs, data dictionary) |
| Redo logs | ib_logfile0, ib_logfile1 | Crash recovery logs |
| Undo logs | undo_001, undo_002 | Transaction rollback data |
| Binary logs | mysql-bin.000001 | Replication and point-in-time recovery |
| Error log | hostname.err | Server errors and startup messages |
| Slow query log | hostname-slow.log | Queries exceeding a time threshold |
| General query log | hostname.log | All queries (debugging only) |
| Configuration file | my.cnf (Linux) / my.ini (Windows) | Server configuration settings |
| Term | Definition |
|---|---|
| Database | A collection of related tables and database objects |
| Table | A structured set of data organized into rows and columns |
| Row (Record) | A single entry in a table (e.g., one employee, one product) |
| Column (Field) | A single attribute of a record (e.g., name, price, date) |
| Primary Key | A column (or combination of columns) that uniquely identifies each row |
| Foreign Key | A column that links to a primary key in another table (creates a relationship) |
| Index | A data structure that speeds up data retrieval (like a book's index) |
| View | A virtual table based on the result of a stored query |
| Stored Procedure | Pre-compiled SQL code stored on the server that can be called repeatedly |
| Trigger | SQL code that automatically executes in response to database events (INSERT, UPDATE, DELETE) |
| Transaction | A group of SQL statements executed as a single unit (all succeed or all fail) |
| ACID | Atomicity, Consistency, Isolation, Durability — properties that guarantee reliable transactions |
| Storage Engine | A component that handles the storage, retrieval, and management of data for a table |
| Replication | Copying data from one MySQL server to another for redundancy or scalability |
| Sharding | Distributing data across multiple MySQL servers horizontally |
| Schema | The structure of a database (tables, columns, indexes, relationships) |
| Query | A SQL statement sent to the database, usually a SELECT statement |
| Join | Combining related rows from two or more tables based on a common column |
| Normalization | Organizing data to reduce redundancy and improve integrity |
| Migration | Moving a database from one version/engine/server to another |
| Connection Pool | A cache of database connections kept open and reused for efficiency |
| Deadlock | A situation where two or more transactions are waiting for each other's locks |
| CRUD | Create, Read, Update, Delete — the four basic operations on data |
| DDL | Data Definition Language — CREATE, ALTER, DROP (structure changes) |
| DML | Data Manipulation Language — SELECT, INSERT, UPDATE, DELETE (data changes) |
| DCL | Data Control Language — GRANT, REVOKE (permissions) |
| TCL | Transaction Control Language — COMMIT, ROLLBACK, SAVEPOINT |
Save your progress and earn XP for completing tutorials.
4 questions · Pass with 70%+
1What does SQL stand for?
2What type of system is MySQL?
3What is the relationship between SQL and MySQL?
4What does ACID stand for?
Technology
MySQL
Lesson group
Getting Started
Progress
25% complete