<< Back to Blog

MySQL vs. MariaDB

Choosing the right database for your needs.

by Derek M | Feb 10, 2020

Tech image

Photo by Christopher Barnes

MySQL (pronounced My-S-Q-L) is an open source relational database management system (RDBMS). MySQL is free and open-source software under the terms of the GNU General Public License and is also available under a variety of proprietary licenses. MySQL AB, the company, was purchased by Sun Microsystems (now Oracle) in 2009.

MariaDB is a community-developed, commercially supported fork of MySQL, intended to remain free and open-source. A fork is when the developers take the original-source code from a product and begin independent development on it. Development is led by the original creators of MySQL, and the MariaDB fork was created when Oracle purchased Sun Microsystems in 2010. MariaDB intended to maintain high compatibility with MySQL, but with recent releases has included new features that diverge more.

Both MySQL and MariaDB are named after Michael Widenius daughters, My and Maria. Michael (Monty) was the lead developer of MySQL before Oracle’s acquisition and is now the lead developer of MariaDB and CTO of MariaDB Corporation AB.

Who Uses MySQL and MariaDB?

Both MySQL and MariaDB boast large followings and large customer bases. Among MySQL’s larger customers are NASA, Tesla, and Youtube. Among MariaDBs larger customers are Redhat, Samsung, and Walgreens.

Some very popular Linux Distributions default to shipping with MariaDB, namely Debian (starting with Debian 9), RedHat Enterprise Linux (starting with RHEL 7), and Ubuntu (starting with Ubuntu 14.04 LTS).

Versioning

MariaDB was originally forked during the MySQL 5.1 timeframe, and as such, the first version carries the 5.1 number. Two additional versions were released between 5.1 and MySQL’s 5.5 version, 5.2 and 5.3. MySQL 5.5 and MariaDB 5.5 were released very close to each other and were meant for high compatibility.

After 5.5, though, the developers of MariaDB decided to make a major version number change, to denote that they were adding specific divergent features to the codebase. They named this release 10.0.

Since that time, MySQL has released 5.6 and 5.7, before doing a major version renumbering themselves, with 8.0 (instead of 6.0) in 2018.

The latest major versions as of this writing are MySQL 8.0 and MariaDB 10.5.

Compatibility

MySQL, being an RDBMS, uses tables, rows, and columns, to store data, as well as queries, triggers, roles, and stored procedures to work with the data. MySQL also uses primary keys to uniquely identify each row, or record, in a table.

Since both MySQL and MariaDB come from the same original code base, they still maintain a high degree of compatibility. Since both the API and underlying protocol are compatible, this means that all connectors, libraries, and applications that work with MySQL should also work with MariaDB. Even most command-line tools are similar, and most have the same names. In general, this allows MariaDB to be a drop-in replacement for MySQL.

That said, MySQL is offered under two versions: the open-source MySQL Community Server, and the proprietary MySQL Enterprise Server. Enterprise is a subscription-based service provided by Oracle Corporation, targeted primarily at the commercial market.

Gradually, the MySQL and MariaDB feature set and internals have diverged. MariaDB has taken the time to document hundreds of incompatibilities between the two, on differing versions, so while many originally hoped that MariaDB would remain a simple branch of MySQL, it has in truth become a full fork, with different specialties and goals.

Licensing and Development

MariaDB is licensed as GPLv2, while MySQL has dual licensing, GPLv2 for the Community Edition, and a proprietary license for the Enterprise Edition. As stated previously, MariaDB is fully open-source, while only the community edition of MySQL is truly open-source.

Oracle’s MySQL development team is the exclusive provider of MySQL, while on the other hand, the development process for MariaDB is more open, where anyone can submit patches to the source tree for consideration to be added to the main code.

Updates

In general, MariaDB has more frequent updates than MySQL. This is both good and bad, in that while newer features and bug fixes are released more quickly, managing more frequent updates can make it a challenge to keep your software up to date.

Features

Both databases offer different features that might appeal to you based on your use cases. Listed here are some features that are exclusive to one or the other.

Authentication: Both MySQL and MariaDB offer mysql_native_password, however, starting with MySQL 8.0, the default is now caching_sha2_password. This enhancement should improve security.

Encryption: MariaDB supports binary log and temporary table encryption, while MySQL does not.

JSON: While both MySQL and MariaDB offer JSON related functions, they differ in their methods of implementation. MySQL, starting with 5.7 implements a native JSON data type, whereas MariaDB only defines an alias, and actually utilizes the column type LONGTEXT.

Keys: MariaDB offers AWS Key management via plugin by default, while you must use the Enterprise Edition if you want this functionality with MySQL.

MySQL Shell: MySQL Shell utilizes the MySQL X protocol, which is not available on MariaDB, to offer an advanced CLI and code editor, as well as scripting capabilities for JavaScript and Python.

Sys schema: Starting with MySQL 8.0, sys schema objects can be utilized for optimization and diagnostic use cases. MariaDB does not have this enhancement.

Threadpool: MariaDB supports connection thread pools, while you must use the Enterprise Edition if you want this functionality with MySQL.

Performance

Benchmarking: As both MySQL and MariaDB have been around for some time now, you can find many public listings of benchmarks with a couple of simple searches. We won’t be doing that here. Rather, we’ll impress upon you the need to perform your own benchmarks, on the solution you’ve chosen, to understand how performance affects your application.

Check out High-Performance MySQL: Optimization, Backups, and Replication by Baron Schwartz, Peter Zaitsev, and Vadim Tkachenko, available at Amazon in multiple formats.

Indexes: Indexes increase performance while at the same time adding a small bit of overhead to the database. Without indexing, searching the database involves reading through entire tables to find relevant rows. With proper indexing, the database engine will find and retrieve specific rows far faster.

MariaDB: MariaDB has several performance optimizations compared to MySQL.

Database Views:Views are virtual tables that can be queried like regular tables. MariaDB is optimized so that only relevant tables are queried when a view is queried, as opposed to MySQL, which queries all tables attached to the view.  

Flash Storage: MariaDB provides the MyRocks storage engine, which is specifically tuned for better performance when using flash storage.

Parallel Execution:Starting with 10.0, MariaDB provides for parallel execution of several queries, automatically.

Thread Pooling: As mentioned before, thread pooling was exclusive to MariaDB and allows for a single thread to handle multiple connections to the database. MySQL has added thread pooling, but only in the Enterprise Edition.

Replication

Both MySQL and MariaDB support replication, allowing you to replicate data from one server to another.

A replica allows you several advantages. You can query the replica for long-running queries without impacting your production instance. You can perform backups on your replica, again without impacting your production instance.

It’s worth noting a couple of caveats, though.

While MariaDB allows you to replicate from MySQL, for example, to migrate your data from MySQL to MariaDB, most MySQL versions will not allow you to replicate from MariaDB.

Additionally, MySQL GTID and MariaDB GTID are different implementations, so when you do replicate, the GTIDs will be adjusted.

Storage Engines

MariaDB supports more storage engines by far, but what’s important is that you choose the storage engine that meets the needs of your application and performance goals.

The list of current storage engines that MariaDB supports can be found here: https://mariadb.com/kb/en/storage-engines/ The list of current storage engines that MySQL supports can be found here: https://dev.mysql.com/doc/refman/8.0/en/storage-engines.html

Documentation

MySQL documentation is owned and managed by the Oracle Corporation.

MariaDB documentation is stewarded by the MariaDB Foundation, but others can contribute.

Conclusion

Both MySQL and MariaDB are powerful databases that you can use to power your applications.

MySQL is a proven database with a strong following.

MariaDB provides a drop-in replacement for MySQL while allowing people to contribute to its open-source product and documentation.

Each has features that are useful that the other does not have.

Before choosing, ask yourself the following questions:

  1. Are you planning to use a feature that is exclusive to one or the other?
  2. Are you planning to use one of the database engines that is exclusive to one or the other?
  3. Is it important for you to have a voice in the community or an impact on the development process of the database you choose?

At this point, you probably have a pretty good idea which you will choose.

References

Wikipedia

Vendor Sites

MariaDB Corporation AB

MariaDB Foundation

MySQL (Oracle)