In a previous article, we laid out the story of the Apache web server, its role in the rise of the internet, and how its market share is being eaten up by competitors like Nginx. Apache is part of the LAMP stack —Linux + Apache + MySQL + PHP — and it’s not an understatement to say that more than half of all the internet owes its existence to LAMP.
Today we’ll take a look at some of the differences between MariaDB and MySQL, two similar yet different database technologies used to power millions of websites around the globe.
MariaDB vs MySQL Differences
Even though MariaDB is a fork of MySQL, these two database management systems are still quite different:
- MariaDB is fully GPL licensed while MySQL takes a dual-license approach.
- Each handle thread pools in a different way.
- MariaDB supports a lot of different storage engines.
- In many scenarios, MariaDB offers improved performance.
What is MySQL
MySQL is a relational database (RDBMS) which first saw the light of day in 1995, created by Michael Monty Widenius and David Axmark. It was created when the market was dominated by Microsoft and Oracle’s proprietary (and pricey) solutions.
With its early adoption of dual licensing — and using GNU GPL for its free version — MySQL paved the way for many other software vendors that came later.
In Michael Widenius’ words about dual licensing:
…since MySQL is an infrastructure product that is easily embeddable into other products, we could sell licenses to those who wanted to embed MySQL into their product but did not want to make their product open source.
Server-deployed web applications, as part of the LAMP stack, don’t usually embed MySQL and distribute their code. This meant that anyone could freely use the software for their own web products.
Less than a decade after its public release, MySQL was dominating the market of open source relational databases.
Google Trends shows that the global web search interest in MySQL peaked between 2004 – 2005:
Some of the noteworthy companies using MySQL include:
- Facebook, a report from 2011 mentions as much as “60 million queries per second, and nearly 4 million row changes per second” and MySQL handling “pretty much every user interaction: likes, shares, status updates, alerts, requests.”
- Netflix’s billing part of its platform
- and many others.
One more factor that contributed to the rise and adoption of MySQL worth mentioning is phpMyAdmin.
PhpMyAdmin is a web-based database administration tool that goes back to 1998, which made its way rather early into the management consoles of shared hosting providers, including cPanel. It is a tool written in PHP which has made administering MySQL on LAMP servers easy. Importing, exporting, composing complex queries, deleting and creating tables, conducting complex searches are just some of the things phpMyAdmin made possible without users ever having to use Linux terminal.
WordPress and MySQL
One of the factors behind MySQL’s popularity is undoubtedly WordPress, which today powers around 60% of the CMS systems or 34% of the entire web.
WordPress was created in 2003 by Matt Mullenweg and Mike Little, as a fork of another project. It was written in PHP, it was using MySQL as its database, and when it appeared, its adoption caught up like wildfire.
WordPress quickly became synonymous with the concept of open source software and so did its underlying server stack. DisplayWP has a nice chart of the minimum required MySQL version for every WordPress release.
One of the factors that boosted the adoption of MySQL was the GPL side of its licensing. Since it is compatible with Linux, it started being included by default in Linux distributions. Today it comes included by default with Ubuntu.
Brief Overview of MySQL and the Relational Database Model
MySQL was conceived as an RDBMS (Relational Database Management System). The Relational Database model goes back to 1970s, as outlined by “Codd’s Twelve Commandments”. To put it briefly, this model structures data into tables that consist of columns and rows. Each row is uniquely identified by a key (Primary Key to use SQL jargon).
These Primary Keys can be used as pegs of a sort that are used by other tables to define a relation to the specific row. So the FOREIGN KEY column in a relational database table will refer to a PRIMARY KEY column in another table, defining a relation between rows in different tables.
As Essential SQL explains, “The primary key consists of one or more columns whose data contained within is used to uniquely identify each row in the table.” Data in primary key columns must be unique, and cannot be empty or NULL. In a relational database “the table has just one primary key, and its definition is mandatory.”
At the same time, “foreign key is a set of one or more columns in a table that refers to the primary key in another table. There aren’t any special code, configurations, or table definitions you need to place to officially “designate” a foreign key.”
This way, with relational databases, it is possible to model the data in sophisticated ways and define connections between various pieces of data. In our simple example above, we have two tables, with rows that can be related to one another, eg. each person owns a car.
We can query this data according to the logic we need, we can filter the result set according to different sets of criteria, and we can construct our query in a far more complex way than we outlined above.
For this reason, relational databases — and databases in general — use domain-specific languages among which the SQL, which stands for Structured Query Language, is the prevalent one if not the only one used by RDBMS.
Acquisition by Sun
In 2008, MySQL AB, the company behind MySQL, was acquired by Sun Microsystems. This company created JAVA, Solaris Unix OS and was a significant contributor to different computer technologies. As Business Wire reported back then:
“Sun Microsystems, Inc. (NASDAQ:JAVA) today announced it has entered into a definitive agreement to acquire MySQL AB, an open source icon and developer of one of the world’s fastest growing open source databases for approximately $1 billion in total consideration”
It will soon prove that this acquisition was not enough to prevent Sun’s downfall, but it paints a picture of how big MySQL was back in those days.
Oracle Corporation is a vendor of the biggest closed source database to this day, Oracle database.
It was a direct competitor to MySQL and virtually the antithesis of the GPL, free, open source software model that MySQL was becoming at that time.
When Oracle purchased Sun, and MySQL with it in 2010 (winning against IBM for it), the FOSS world saw that as something as “sinister” as a Borg attack in Star Trek. One user recollects the event on Quora:
MySQL was a grave threat to Oracle – at the time the Oracle database accounted for something north of 80% of all revenue (and given the skeleton crew needed to maintain it, even more of the profits).
MySQL was making serious inroads – large Fortune 50 companies with site licenses that cost millions were shifting databases (especially read-only ones) from Oracle to MySQL because the administrative overhead was that much lower. I know, I helped do some of these.
Many in the MySQL community wanted to add features that would make using even a free version of Oracle obsolete. MySQL was definitely going down that path. Tools were maturing and Larry was afraid.
So Oracle bought MySQL to make sure it would have a control over the brand, scatter the community and save its flagship from the unwashed masses.
This was a logical conclusion, because MySQL, at that time, became so popular that it might have been viewed as a real threat to Oracle’s core business. As Geekflare’s Ankush Thakur put it, MySQL became so popular that pretty soon, developers forgot that SQL and MySQL were two different things.
Before the acquisition even happened, at the end of 2009, Monty Widenius, who left the MySQL team in that year to establish his own fork and database company, published a dramatic appeal on his blog (we will quote just the beginning):
Help saving MySQL
I, Michael “Monty” Widenius, the creator of MySQL, am asking you urgently to help save MySQL from Oracle’s clutches. Without your immediate help Oracle might get to own MySQL any day now. By writing to the European Commission (EC) you can support this cause and help secure the future development of the product MySQL as an Open Source project.
The acquisition nonetheless went through a month later, to the dismay of many in the open source community. Widenius had already left Sun, formed Monty Program AB, and forked MySQL, laying the foundations for MariaDB. All while taking many MySQL developers with him.
To this day, people are still questioning the legitimacy of Monty’s fears. Especially, since the worst scenario didn’t happen at all: Oracle didn’t acquire MySQL only to kill it.
Some argue that MySQL was bought by Oracle as nothing more than a “collateral victim” of the acquisition of Sun. Back in 2009 those who had their eyes on the database market had reasons to worry.
Warnings were there. The developer of MySQL’s main storage engine, InnoDB, a company from Finland, was acquired by Oracle in 2005. Later on, they were fully merged into Oracle, terminating the original company. In 2006, Oracle bought off the creators of Berkeley DB, provider of another, less important BDB storage engine. They were circling around.
What is MariaDB
MariaDB had its first release in October 2009, with version 5.1.38 Beta, based on MySQL 5.1.38. It was a fork meant to “to ensure that the MySQL code base would be free forever”.
At the time of forking, the most common fear was that the acquisition was a hostile takeover with the goal of killing MySQL. That concern, at least partly, proved to be unfounded.
Again in 2009, Monty Program AB and Percona, a company providing premium MySQL services, established the Open Database Alliance. Their goal was “to unify all MySQL-related development and services, providing a solution to the fragmentation and uncertainty facing the communities, businesses and technical experts involved with MySQL.”
The idea was “to become the industry hub for the MySQL open source database, including MySQL and derivative code, binaries, training, support, and other enhancements for the MySQL community and partner ecosystem”
Looking back at it: it is possible that these steps have prevented a worse scenario for the famous database.
MariaDB vs MySQL: Compatibility
The whole point of MariaDB’s fork of MySQL (named after Widenius’ daughter) was to secure the future access to MySQL and its further development. This is why MariaDB was conceived as a full binary replacement — a “drop-in” replacement, so to say — enabling all users of MySQL to exchange one for the other on their systems.
MySQL is a client-server application, and both its server program mysqld, its client mysql, and auxiliary programs, like mysqldump, retain the same name with MariaDB.
Replacing MySQL with MariaDB becomes a seamless process for most applications and purposes, especially WordPress. Existing software, from popular CMS tools to apps like phpMyAdmin, just work out of the box, and actual data can be exported/imported from one into another without any changes.
- data and table definition files are compatible.
- all client APIs and protocols are compatible.
- Filenames, binaries, and paths are the same on MySQL and MariaDB.
- Ports and sockets are the same.
- All MySQL connectors — PHP, Perl, Python, Java, and others — work with MariaDB.
- MySQL client package works interchangeably with MariaDB just as with MySQL.
Monthly merges are conducted to ensure compatibility and to get any new features and bug fixes from Oracle.
MariaDB vs MySQL: The Reasons Behind Forking
There were multiple reasons behind the MariaDB release. The fears that Oracle would simply kill its growing competitor to protect its more lucrative main product was surely one of the biggest ones. Users would have lost a fantastic and free product!
Other reasons were related to ensuring that MySQL would have stayed free and open source. Today, MariaDB is fully GPL licensed with its entire set of features, while MySQL keeps a dual-license approach, with premium features licensed under proprietary, paid license:
“MySQL Enterprise Edition includes the most comprehensive set of advanced features, management tools, and technical support to achieve the highest levels of MySQL scalability, security, reliability, and uptime. It reduces the risk, cost, and complexity in developing, deploying, and managing business-critical MySQL applications.”
If we compare the two here, MariaDB has clear advantage provided by the GPL license it is released upon. Because of the proprietary code base, Oracle can’t legally take advantage of MariaDB code and merge it into their database.
Widenius promised: “When Oracle will release a closed source extension for MySQL, we will also release an open source one.”
Another reason behind the fork was to keep the project “open” in the sense of it being a community-driven project (like WordPress), whose direction and development are open just like its license. If we take a look at the commit log, it is easy to conclude that most of the MySQL code comes from in-house developers. Oracle’s developers give thanks to occasional and notable contributions from the community, for example, but that is far from the MariaDB’s openness and far from what MySQL used to be.
To put things into perspective, MariaDB server repository at the time of this writing has more than 186k commits, 370+ branches, and 200 contributors. MySQL, on the other hand, has more than 148k commits, 9 branches, and 72 contributors.
The discussion about MariaDB development, its direction, voting about the features, etc. is done on a publicly available mailing list:
Besides this one, there is also Maria Discuss mailing list.
Maria Captains are a team of trusted developers to whom developers can submit patches. As team’s page on Launchpad says:
“The captains are trusted developers with write access to the main MariaDB trees. If you want to have a patch into the tree, submit it to the maria-developers list and one or more of the captains will work with you to get the patch reviewed, approved and finally pushed into the appropriate MariaDB tree.”
There have been some occasions where MariaDB lively development process proved its advantage over Oracle’s closed one.
At the end of 2012, the MariaDB foundation was formed to oversee the development of the database.
Soon after the fork, many original MySQL developers jumped ship and joined the MariaDB project. Linux vendors like Red Hat, CentOS, Arch Linux, Debian, OpenSuse, Slackware, Fedora switched to MariaDB as the default RDBMS, as well as BSD distributions, FreeBSD and OpenBSD, while Ubuntu includes MariaDB. The whole list can be found here.
Companies such as Alibaba Cloud, Tencent, IBM, Microsoft, Booking.com became platinum sponsors.
For Kinsta, as the best managed WordPress hosting, it is interesting to mention that among MariaDB Foundation board of directors are people from Automattic, a clear sign that creators of WordPress have embraced MariaDB.
In the years following the split, MariaDB had a lively development, so much that due to the whole set of new features introduced in 2012, MariaDB jumped from 5.* version number, compatible with MySQL, to 10.0, wanting to reflect the leap in features it had achieved.
Because of performance reasons, the Wikimedia Foundation announced in 2013 it was switching Wikipedia to MariaDB. The same thing happened with Google, and its users’ list now includes Deutsche Bank, DBS Bank, Nasdaq, Verizon, Craigslist, and others.
Among MySQL users, we have GitHub, US Navy, NASA, Tesla, Netflix, WeChat, Facebook, Zendesk, Twitter, Zappos, YouTube, Spotify.
Since its first release, interest in the MySQL successor had been steadily growing, as Google Search Trends shows:
MariaDB vs MySQL: Key Differences
While MariaDB may have started off as fully compatible with MySQL, we can expect that their paths diverge more in the future.
In his last blog post, Widenius congratulates Oracle on their work on the version 8.0 of MySQL, outlining some differences and caveats such as:
Thread Pool: similar to the issue Nginx server solves compared to Apache, MySQL was assigning threads to every client connection, and this, which could be compared to booting up an entire program in a pc, was simply inefficient. MariaDB introduced its own solution to this in version 5.5
MariaDB introduces microseconds in its temporal datatypes.
Storage Engines: MariaDB uses include XtraDB, InnoDB, MariaDB ColumnStore, Aria, Archive, Blackhole, Cassandra Storage Engine, Connect, CSV, FederatedX, Memory storage engine, Merge, Mroonga, MyISAM, MyRocks, QQGraph, Sequence Storage Engine, SphinxSE, Spider, TokuDB. ColumnsStore is interesting performance-wise, cause it makes possible linear scaling to handle petabytes of data. More about it on their blog.
Database Views are a feature in which MariaDB introduces significant optimizations by querying only the necessary tables.
Here you can find the complete list of differences between MariaDB vs MySQL and the advantages of the former when compared with the latter.
MySQL is under the corporate umbrella of the biggest commercial database vendor in the world. With so many full-time engineers working around the clock to develop premium new features, we already have some points where they diverge. MariaDB, on the other hand, usually catches up when it comes to premium additions but that is not always immediate and there are no guarantees.
Having said so, though, there are many scenarios in which MariaDB offers improved performance. Add to this more agile patches and updates, a more stable open source future, and a bit more optimism and you’ll see why at Kinsta we’re not only fans but also use MariaDB as part of our performance-driven server stack.