Choosing between MariaDB and MySQL can be tough. MariaDB's origins as a fork of MySQL bring so many surface-level similarities that it can feel like picking a favorite identical twin based on their looks.
If you're working on a small-scale project, you might decide based on your love of open source or a desire to pick the most popular system. If you need something that will handle several terabytes of data for large numbers of users, the differences between the two become more important.
In this article, we'll explore MariaDB and MySQL's history, popularity, similarities, and key differences. We'll also discuss when and why a team or solo dev might choose one over the other.
What Is MariaDB vs MySQL in Brief?
MySQL is a relational database management system (RDBMS) offered under dual licenses.
MySQL Community Edition and MySQL NDB Cluster are open source under the GNU General Purpose License v2 (GPLv2). MySQL Standard Edition, MySQL Enterprise Edition, MySQL NDB Cluster CGE, MySQL Embedded, and HeatWave are available only under a proprietary license.
Originally released in 1995 by the Sweden-based MySQL AB company, MySQL was acquired by Sun Microsystems in 2008. Oracle Corporation took ownership of it in 2009 when it bought Sun Microsystems.
Michael Widenius (one of the original developers of MySQL and founders of MySQL AB) created MariaDB as a fork of MySQL out of concern for how Oracle would potentially handle MySQL.
MariaDB Community Server and MariaDB Enterprise Server are both licensed under GPLv2.
MariaDB and MySQL were once so similar that until MariaDB 5.5's release, it was a drop-in replacement for MySQL. However, it diverges more from its origins with each new release.
The top 10 RDBMSes as of December 2024. (Image Source)
Both are popular, with MySQL ranking at #2 and MariaDB at #7 or #10 for RDBMS by usage, depending on the survey.
MySQL enjoys widespread popularity due to its simplicity, scalability, performance, and backing by Oracle. While Oracle elicits strong opinions from many tech professionals, its ubiquity in databases and other software has made it a mainstay for many enterprise-level businesses.
MariaDB is a worthy competitor that offers much of what MySQL does except with faster performance and without the hefty costs and lock-in risk of Oracle software. It also has a firmer foot in the open-source community.
How Are MariaDB and MySQL Similar?
At one point in time, MariaDB and MySQL were identical. Although this is no longer true, they still have more in common with each other than they do with most other RDBMSes.
MariaDB and MySQL overlap significantly in the following ways:
-
Syntax: MariaDB and MySQL largely share the same SQL syntax. There are some differences in writing statements, such as MySQL lacking a CREATE SEQUENCE statement, which MariaDB, PostgreSQL, and some other RDBMSes have. However, most basic statements will look the same.
-
Data types: There is a lot of overlap in their data types, as evidenced by the table above. They share nearly 40 types. The main differences show up in MariaDB's additional string types (ROW, UUID, INET4 for IPv4, and INET6 for IPv6) and MySQL's JSON type.
-
Security features: Both offer end-to-end encryption via Transport Layer Security (TLS) for data in transit and Transparent Data Encryption (TDE) for data at rest, authentication and authorization with plugins or user credentials, role-based access control, and more. Some security features may only be available in select commercial offerings.
-
Storage engines: MariaDB and MySQL use InnoDB as their default storage engine. They also support many of the same storage engines, including MyRocks, MyISAM, BLACKHOLE, and MERGE.
-
Indexing: InnoDB supports B-tree structured indexes by default; MariaDB and MySQL can create indexes with more structures, like Hash and R-tree, with other storage engines.
Let's look at the syntax similarity a little closer by comparing CREATE TABLE statements in MySQL, MariaDB, Oracle Database, and Microsoft SQL Server.
We'll make a table of different databases with an automatically incrementing database ID as our primary key. We'll also create NOT NULL columns for the database name, the year it was created, and the company that owns it.
This is how it would work in MySQL and MariaDB:
CREATE TABLE Rdbmses( DbID INT AUTO_INCREMENT PRIMARY KEY, Name VARCHAR(32) NOT NULL, YearCreated DATE NOT NULL, Company VARCHAR(64) NOT NULL );
In Oracle Database, it would look like:
CREATE TABLE Rdbmses( DbID NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, Name VARCHAR2(32) NOT NULL, YearCreated DATE NOT NULL, Company VARCHAR2(64) NOT NULL );
In SQL Server, you would write it as:
CREATE TABLE Rdbmses( DbID INT IDENTITY(1, 1) PRIMARY KEY, Name VARCHAR(32) NOT NULL, YearCreated DATE NOT NULL, Company VARCHAR(64) NOT NULL );
As seen above, MySQL and MariaDB can use the same CREATE TABLE statement. The AUTO_INCREMENT syntax is also a bit simpler than the others.
How Are MariaDB and MySQL Different?
MySQL and MariaDB differ in some important ways that may matter to developers and their teams when choosing their DBMS.
JSON Handling
MySQL and MariaDB handle JSON in two different ways.
MariaDB treats JSON as an alias of LONGTEXT, meaning it's treated as a string. MySQL has a built-in JSON data type and treats it as a binary object.
Both have many JSON-related functions. For example, MySQL and MariaDB have a JSON_VALID() function that returns a boolean indicating whether a given string is formatted correctly according to the JSON standard.
MariaDB claims that treating JSON as text instead of binary results in faster JSON function performance, but there is no benchmark given for this claim.
PL/SQL Support
MySQL and MariaDB both have their own SQL extensions based on SQL/Persistent Stored Modules (SQL/PSM).
Procedure Language for SQL (PL/SQL) is the extension of SQL used in Oracle Database. It's block-oriented and has deeper functionality for stored procedures, triggers, exception handling, and more.
MariaDB can be made compatible with much of PL/SQL by using SET SQL_MODE='ORACLE';. This lets you use Oracle Database-style syntax like data types and cursor variables.
PL/SQL support is great for:
- Migrating from Oracle DB to MariaDB
- DB administrators who switch to MariaDB from an Oracle DB background
- Gaining some of the strengths of PL/SQL while saving on Oracle DB costs
For example, in the Oracle Database CREATE DATABASE statement from earlier, MariaDB could use much of the same syntax with some minor alterations, like changing "GENERATED AS ALWAYS IDENTITY" to "AUTO_INCREMENT."
Storage Engine Choice
MariaDB and MySQL support a lot of storage engines, but MariaDB has many more options.
MariaDB supports nearly 20 storage engines (see the chart above), while MySQL supports a little over 10.
Let's look at a few examples.
Aria is MariaDB's non-transactional storage engine for read-heavy use cases. It's similar to MyISAM but has faster querying, better caching, and is crash-safe. You can use it for more performant aggregate workloads, like statements with GROUP BY, ORDER BY, or DISTINCT.
Spider is MariaDB's storage engine for sharding that supports xa transactions. A Spider database allows you to access remote databases, pull data from them, and join them as if they were one --- even if they're running on different storage engines.
Network DataBase (NDB) is MySQL's high-availability in-memory storage engine for clustering multiple database servers together to act as one with automatic partitioning. It has a shared-nothing architecture, where each server relies on its own memory and storage for better performance.
Community Edition Comparison
Both companies have a community edition under GPLv2, but MariaDB provides more for free compared to MySQL.
MariaDB's community edition has a few more features than MySQL's, like dynamic thread pools, which accommodate higher concurrent users with a lower risk of performance dips. Thread pooling is only available in the enterprise version of MySQL.
MariaDB Community Edition also comes with the ColumnStore storage engine, which offers more robust Online Analytical Processing (OLAP) functionality than MySQL Community Edition. For the strongest OLAP and analytical workload performance, you would need to pay for MySQL's HeatWave.
It's worth noting that Oracle also has a free version of MySQL Enterprise Edition for developers to learn and experiment with, but it can't be used commercially without purchasing license(s).
JavaScript Stored Programs
MySQL Enterprise Edition and HeatWave have a feature called JavaScript Stored Programs that enables the use of JavaScript in stored procedures and stored functions.
You can use JavaScript-stored programs for extracting, formatting, validating, compressing, and transforming data better than MySQL's standard stored procedures and functions. It also saves headaches for devs and database administrators (DBAs) who would have to move data around to do this with JavaScript otherwise.
MariaDB lacks this feature completely.
Which Should You Pick Between MySQL and MariaDB?
Now that you understand more about their similarities and differences, we'll discuss how to choose one over the other.
Stances on Oracle and Open Source
Oracle offers many great products, but opinions about the company can be very divisive. Some businesses go all-in on the Oracle ecosystem, some use one or two Oracle products alongside those of other companies to reduce vendor lock-in risk, and some avoid Oracle altogether.
Adding to that, some developers seek out open-source software to be part of a community that creates and shares great tools for free. While MySQL Community Edition is open source, MySQL is less so with its multiple proprietary editions.
If you feel strongly about Oracle in a positive way and have a use case for which Oracle Database isn't more suited, MySQL could be a solid choice. If your opinion of Oracle is negative or you want something that is more fully open source, then MariaDB would likely be better.
Feature Preferences
If your planned use case would greatly benefit from some of the features mentioned earlier, you'll have an easier time choosing.
For companies or individuals that want strong OLAP support, greater compatibility with Oracle DB, or more storage engine choices, MariaDB would win out.
For those that want better JSON handling, the ability to create JavaScript stored programs, or stronger enterprise-level OLAP, MySQL is the way to go.
Alternatively, if your database primarily deals with JSON, you may consider a NoSQL database like Redis, Cassandra, MongoDB, or DocumentDB.
Performance Needs
Over the years, MySQL and MariaDB have alternated between which one performs better --- better, as in faster statement processing, better resource utilization, and similar.
As of 2024, MariaDB is 13-16% quicker than MySQL on a small server and 11% faster on a medium one, averaged over several benchmarks for different SQL statements. MariaDB also experiences fewer CPU performance regressions.
The pendulum may swing in the other direction in the future, but for now, MariaDB is faster and more efficient under benchmark conditions.
Employability
For early career devs and computer science or software engineering majors, it might be helpful to consider this question from the perspective of which has more usage and job openings.
Stack Overflow's 2024 Developer Survey showed that 39.4% of professional developers use MySQL (2nd overall) and 17.1% use MariaDB (7th overall).
There are also more backend engineering, database administration, and similar jobs that require MySQL experience than MariaDB.
Going by popularity and job availability, MySQL seems to have an edge. However, both are so similar that many of the skills developed by learning one will transfer to the other.
Database Migrations
If you plan on migrating your current database to MySQL or MariaDB, you'll want to do so carefully. Some migrations will be easier than others.
For example, if you're migrating from MySQL to MariaDB, the process should be relatively straightforward without JSON data. If there is any JSON present, there may need to be some conversion in the MySQL database before migrating. Migrating in the opposite direction will require some extra work for JSON data, as well.
Another instance of an easier migration is Oracle Database to MariaDB, thanks to the previously discussed PL/SQL compatibility.
Be sure to check official documentation to see what each company recommends. There may be guides or tools you can use, like the MySQL Workbench Migration Wizard, which can migrate PostgreSQL to MySQL.
Conclusion
Now that we've compared MariaDB to MySQL and seen how they differ, we hope your choice is easier.
Given how similar they are in many ways, early career developers and DBAs can't go wrong with either choice. The same applies to small-scale projects. You might go with MariaDB for its more robust community edition or MySQL for its widespread popularity.
For larger implementations, teams heavily invested in Oracle products might want to choose MySQL if they're happy with their vendor. Other teams might opt for MariaDB to avoid vendor lock-in or to pick the fully open-source option.