MariaDB vs MySQL: differences

MariaDB started as a fork of MySQL and now evolves separately, with its own JSON, replication and features. For a typical app both work, and the choice usually comes from your stack.

Updated 5 min read

Learning objectives

After reading this article you will be able to:

  • Understand where MariaDB comes from and why it looks like MySQL
  • Compare JSON, sequences, RETURNING, versions and replication
  • Decide between MariaDB and MySQL for a new project or a migration
On this page

If you have ever installed a MySQL server on Linux, you have probably run into MariaDB: many distributions and tutorials install one in place of the other, and the mysql and mysqldump commands work on both. That makes them look like the same thing.

They aren't. MariaDB started as a fork of MySQL and, with each release, gained features that MySQL doesn't have (and the other way around). In a simple app you won't notice; once you rely on JSON, replication or authentication, the differences show.

Original MySQLshared base:protocol, SQL,mysqldumpMySQLOracleMariaDBforkonly in MySQLBinary JSONGroup Replicationonly in MariaDBINSERT … RETURNINGCREATE SEQUENCEGalera Clusterreplicationincompatible
Same origin and the basics in common; each branch gained its own features, and their replication does not interoperate.

What are MySQL and MariaDB?#

MySQL is a relational database maintained by Oracle. Its default storage engine is InnoDB, with ACID transactions and row-level locking. It has two release tracks: LTS, which only receives fixes, and Innovation, which brings new features. The support dates for each series are in Oracle's end-of-life policy. See what MySQL is.

MariaDB is a fork of MySQL maintained by the MariaDB Foundation and the MariaDB company. It ships LTS releases regularly, each with a few years of community support, and releases that are not LTS get short support. The MariaDB maintenance policy shows which series are supported.

Watch the version numbers: a higher number on MariaDB does not make it "newer" than MySQL, nor does it make the two versions equivalent. The two stopped following the same numbering years ago, and that is part of the divergence.

Why do they look so much alike?#

Because they share an origin. The client protocol, most of the SQL syntax, the utilities (mysql, mysqldump) and the most common drivers work on both. An app that only uses SELECT, INSERT, indexes and simple transactions usually runs on either one without changing a line.

The MariaDB documentation itself says versions 10.0 and 10.1 were only limited drop-in replacements for MySQL 5.6 and notes implementation differences. The more advanced features you use, the lower the compatibility.

What has changed between them?#

Criterion MySQL MariaDB
Maintainer Oracle MariaDB Foundation and the MariaDB company
JSON type Internal binary format, validated on input Alias for LONGTEXT with validation through CHECK
INSERT ... RETURNING Not available Yes, since 10.5
CREATE SEQUENCE Not available Yes, since 10.3
Cluster replication Group Replication Galera Cluster
GTID MySQL format Its own, incompatible format
Authentication Has sha256_password and caching_sha2_password No sha256_password; caching_sha2_password only since 11.4.9, 11.8.4 and 12.1

Three of these points need more detail.

How does each one handle JSON?#

In MySQL, a JSON column stores the document in an internal binary format, validates the input and lets you look up keys without rereading the whole document. Invalid input fails with an error:

sql
INSERT INTO events (data) VALUES ('[1, 2,');
-- ERROR 3140 (22032): Invalid JSON text: ...

In MariaDB, JSON is just an alias for LONGTEXT COLLATE utf8mb4_bin, created for compatibility. The value is stored as text, unchanged, and validation comes from a CHECK constraint added automatically. The JSON_EXTRACT, JSON_VALUE and similar functions exist in both, but storage and comparison are not identical, and the MariaDB documentation itself warns that it doesn't support MySQL 5.7's packed JSON objects. If you move JSON columns between the two, test your queries and indexes.

What does MariaDB have that MySQL doesn't?#

Two things anyone coming from PostgreSQL or Oracle will recognize. The first is INSERT ... RETURNING, which returns the written rows in the same query:

sql
INSERT INTO users (name) VALUES ('Ana') RETURNING id, name;

In MySQL, you run the INSERT and then read LAST_INSERT_ID() or run a SELECT. The second is the sequence, a number generator independent of any table:

sql
CREATE SEQUENCE orders_seq START WITH 100 INCREMENT BY 10;
SELECT NEXTVAL(orders_seq);

CREATE TABLE orders (
  id INT PRIMARY KEY DEFAULT NEXTVAL(orders_seq),
  total DECIMAL(10,2)
);

MariaDB also has a VECTOR(N) type for similarity search, available since 11.7. MySQL has its own VECTOR type, but check your edition's documentation for which distance functions and indexes it includes before porting embedding code.

What about replication?#

Here the incompatibility is explicit. According to MariaDB's compatibility page, its GTID is not compatible with MySQL's (a MySQL 5.6 server can't act as a replica of a MariaDB 10.0 server) and the system variables are different. The same page says MySQL's Group Replication is incompatible with MariaDB's Galera Cluster. If you plan a multi-node cluster or read replicas, pick the engine first and build replication with its own tools.

Can you swap one for the other?#

Yes, carefully. Migration is usually simpler when the app only uses standard SQL. The things that break most often are JSON columns, user accounts with sha256_password authentication, performance_schema and sys, replication and views created by old versions. After starting MariaDB on top of a MySQL data directory, you still need to run mysql_upgrade (called mariadb-upgrade in recent versions) to update the system tables.

A safe plan: export with mysqldump, restore on a test server running the other engine, run your test suite and compare query plans with EXPLAIN. See also how to back up a database.

Which one should you choose?#

Choose MySQL if your stack already requires it, if your software's documentation (CMS, ERP, framework) lists MySQL first or if you want Oracle's LTS track.

Choose MariaDB if you want RETURNING, sequences, Galera or MariaDB's VECTOR, or if your Linux distribution already installs it by default.

Popular software accepts both. WordPress, for example, recommends supported LTS versions of both. In that case, pick whichever your provider offers and stay on a supported version.

Either way, choose a supported LTS series: a version past its end of support no longer gets security fixes. If your question is broader (relational or NoSQL, PostgreSQL or MySQL), see which database to choose and PostgreSQL vs MySQL.

How to do this on Square Cloud#

Square Cloud offers MongoDB, PostgreSQL, MySQL and Redis hosting starting on the Standard plan; the Hobby plan doesn't include database hosting. Of the two engines compared here, MySQL is the one available, always on a recent version.

You create the database in the dashboard, and it is provisioned in seconds in the same datacenter as your applications (about 1 ms average latency). TLS is mandatory, with the certificate downloaded from the dashboard. You take manual snapshots whenever you want, and every plan that includes databases also has a daily automatic snapshot.

You connect your application with the connection URL the dashboard gives you. If your app only uses plain SQL, it runs on the hosted MySQL without changes. If it depends on RETURNING or sequences, adjust the code first, because MySQL doesn't have them. Galera is out too: the database is a single node. See the MySQL hosting page.

Database hosting

MongoDB, PostgreSQL, MySQL and Redis next to your app

Learn more

FAQs

Is MariaDB the same as MySQL?

No. MariaDB began as a fork of MySQL, but today it is a separate project. Both speak similar SQL and use a similar client protocol, but they already differ in features, types and behavior.

Is MariaDB a drop-in replacement for MySQL?

Only partly. The MariaDB documentation says that from version 10.0 on, migrating from MySQL is usually easy, but it lists incompatibilities in JSON, GTID, authentication and group replication. Test the migration first.

Does WordPress work with both MariaDB and MySQL?

Yes. The WordPress hosting handbook recommends supported LTS versions of both databases.

Which is faster, MariaDB or MySQL?

It depends on the query, the indexes and the version. Generic benchmarks don't help much. Run EXPLAIN and a test with your own data on both before deciding.

Next articleSQLite vs a database server: when to switchSQLite vs a database server like PostgreSQL or MySQL: how each handles writes, networks and size, with a side-by-side table and clear signs it is time to switch.

More in Databases

See all 24 articles