Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 40 ยท Getting Started

Introduction to MariaDB

Learn what MariaDB is, how it relates to MySQL, how a client talks to the server, and which features make it a popular open source relational database.

MariaDB is a free, open source relational database server. You store data in tables made of rows and columns, and you read and change it with SQL. It powers websites, shops, internal tools and large platforms, and it ships as the default "MySQL-compatible" database in many Linux distributions.

This course teaches MariaDB from the first CREATE DATABASE to replication and backups. MariaDB itself cannot run inside your browser, so the lessons use two kinds of examples. Everything that is standard SQL runs live in the editors on this page (they use SQLite compiled to WebAssembly). MariaDB-only syntax such as storage engines, stored procedures or SHOW commands appears in read-only blocks, and each one is paired with a runnable stand-in that shows the same idea.

A short history

MariaDB started in 2009 when Michael "Monty" Widenius, the creator of MySQL, forked the code after Oracle announced it would buy Sun Microsystems, the owner of MySQL. The name comes from his younger daughter, Maria (MySQL was named after his older daughter, My). The goal was simple: keep a community-governed, fully open database that stays a drop-in replacement for MySQL.

For the first versions that was true. Today the two have drifted apart. MariaDB has its own optimizer work, its own storage engines, sequences, system-versioned tables, INTERSECT and EXCEPT, RETURNING clauses and a different JSON implementation. Basic SQL, the protocol and most client tools still work with both, so what you learn here carries over to MySQL for the large majority of everyday work.

What you get

  • Relational model. Tables, keys, foreign keys, joins and transactions (with the InnoDB storage engine).
  • Pluggable storage engines. InnoDB for general use, Aria for crash-safe internal tables, MEMORY for temporary lookups, ColumnStore for analytics. You will meet them in storage engines.
  • Standard SQL plus extras. Window functions, recursive CTEs, INTERSECT, EXCEPT, sequences, generated columns and more.
  • Replication and clustering. Primary/replica replication and Galera Cluster for multi-primary setups.
  • A large tool ecosystem. The mariadb command-line client, HeidiSQL, DBeaver, phpMyAdmin and drivers for every common language.

How a client talks to the server

MariaDB is a server process (mariadbd, formerly mysqld) that listens on TCP port 3306 by default. Your application or a tool connects, sends SQL text, and receives result sets. Nothing about your data lives in the client.

flowchart LR
  A["Your app or CLI"] -->|"SQL over TCP 3306"| B["mariadbd server"]
  B --> C["Parser and optimizer"]
  C --> D["Storage engine: InnoDB"]
  D --> E[("Data files on disk")]

The client sends SQL, the server plans it, and a storage engine reads or writes the files.

The hierarchy inside the server is: a server holds many databases (also called schemas, the two words mean the same in MariaDB), a database holds tables, and a table holds rows made of columns.

One server, many pieces

Server One mariadbd process
Databases Named containers
Tables Rows and columns

A database is also called a schema.

1 / 2

Your first query

A "hello world" in MariaDB is a SELECT without a table. Try it, then query a real table from the sample shop database:

SQL SELECT without a table ยท database: shop

Press Run (or Ctrl + Enter) to see the result here.

SQL Your first table query ยท database: shop

Press Run (or Ctrl + Enter) to see the result here.

On a real MariaDB server you would also ask the server about itself. These statements are read-only here:

SQL
SELECT VERSION();          -- for example 11.4.2-MariaDB
SELECT DATABASE();         -- the currently selected database, or NULL
SELECT CURRENT_USER();     -- the account you are logged in as
SHOW DATABASES;            -- every database you may see

MariaDB or MySQL?

Choose by your environment, not by fashion. If you manage your own Linux server, MariaDB is the default in Debian and many other distributions. Cloud providers offer both. The main differences that matter to a developer:

Topic MariaDB MySQL
License and governance GPL, MariaDB Foundation GPL with Oracle as owner
Extra engines Aria, ColumnStore, Spider, MyRocks InnoDB, NDB
Sequences CREATE SEQUENCE Not available
System-versioned tables Yes (FOR SYSTEM_TIME) No
INTERSECT / EXCEPT Yes Yes (8.0.31 and later)
JSON type Alias of LONGTEXT with checks Native binary type

This course names a difference whenever it affects what you type, so you can move between the two with confidence.

How the course is organized

The nine chapters build on each other: getting started, basic SQL, data types and engines, joins and subqueries, functions and window functions, stored programs, indexing and performance, operations (replication, backup, security) and finally projects. Each lesson ends with a short quiz. A good pace is one lesson per sitting with the examples edited, broken and fixed.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why was MariaDB created?

    MySQL's original creator forked the code in 2009 to keep a community-governed, open source database that stays compatible with MySQL.
  2. 2. Which default TCP port does the MariaDB server listen on?

    3306 is the traditional MySQL/MariaDB port. 1433 is SQL Server, 5432 is PostgreSQL and 27017 is MongoDB.
  3. 3. In MariaDB, what is the relationship between a database and a schema?

    MariaDB uses CREATE SCHEMA and CREATE DATABASE as synonyms. This differs from PostgreSQL, where a schema lives inside a database.
  4. 4. Which of these is a MariaDB feature that MySQL lacks?

    MariaDB has sequence objects and system-versioned tables. MySQL has neither, while the other three exist in both.

Summary

  • MariaDB is an open source relational database, forked from MySQL in 2009 and still largely compatible with it.
  • A client sends SQL to the mariadbd server on port 3306; a storage engine does the actual reading and writing.
  • A server contains databases (schemas), which contain tables, which contain rows.
  • Standard SQL examples run in your browser here; MariaDB-specific features are shown read-only with runnable stand-ins.

Next: Installing MariaDB