MongoDB vs MySQL
MongoDB is a document database. MySQL is a relational database, and one of the two WordPress recommends. This comparison sets them side by side on six aspects and says which fits which application.
MySQL has a JSON column type and a Document Store mode for schema-less collections. MongoDB has multi-document transactions and a left outer join. The differences that remain are in how each stores a record, how it scales writes, and how it is licensed.
Prices and other facts are as of October 29, 2026. Vendors change prices; confirm them on the vendor’s own pricing page. Independent analysis: neither project nor any vendor named here paid for or reviewed this page.
Which to choose
Choose MongoDB when
- each record is a nested object your code reads and writes whole
- records of one type vary in shape and change often
- you expect to shard writes across many machines
Choose MySQL when
- the data is relational and queries join several tables
- your software is built for it, such as WordPress on PHP
- you want a GPL license or a managed service from any major cloud
Who makes each
MongoDB, Inc. develops MongoDB and sells Atlas, its managed service. It was founded in 2007 as 10gen.
Sun Microsystems acquired MySQL AB on February 25, 2008. Oracle completed its acquisition of Sun on January 27, 2010, and now develops MySQL. Oracle sells HeatWave, its managed MySQL service.
How they compare
Compared as of MongoDB 9.0 and MySQL 9.7 LTS, with list prices as of October 2026.
Data model and schema
MongoDB
BSON documents in collections, with nested documents and arrays, up to 16 mebibytes each. Documents in one collection need not share fields. Validation rules can be added later.
MySQL
Rows in tables with a defined schema. A JSON column stores validated JSON in a binary format, limited by max_allowed_packet. JSON is indexed through generated columns or multi-valued indexes on arrays.
In MongoDB the document is the record; in MySQL, JSON is a column inside a row.
Querying and joins
MongoDB
The MongoDB Query API and aggregation pipeline. $lookup performs a left outer join to a collection in the same database, including sharded collections.
MySQL
SQL with inner, left, right, cross and natural joins. JSON_TABLE turns JSON into rows that SQL can join.
Queries across many related tables are simpler in MySQL.
Transactions
MongoDB
A write to one document is atomic. Multi-document transactions run on replica sets and sharded clusters, at a higher cost than single-document writes.
MySQL
InnoDB, the default engine, runs ACID transactions with commit and rollback, row-level locks and foreign keys. A schema change commits the open transaction and cannot be rolled back.
MySQL expects multi-row transactions; MongoDB expects most writes to touch one document.
Scaling out
MongoDB
Replica sets elect a new primary automatically. Sharding is built in: mongos routers and config servers spread collections across shards.
MySQL
Replication is asynchronous by default, with a semisynchronous option. InnoDB Cluster adds Group Replication with automatic failover on at least three servers. Sharding comes from Vitess, a separate project.
Both fail over automatically; MongoDB includes sharding, and MySQL on InnoDB adds it with Vitess.
License
MongoDB
Community Server is under the Server Side Public License (SSPL) for versions released on or after October 16, 2018. The Open Source Initiative has not approved the SSPL. Its service clause applies when you offer MongoDB itself as a service to third parties.
MySQL
GPLv2, or a commercial license from Oracle for software that ships MySQL without releasing its own source under the GPL.
Applications that only use either database are not caught by its copyleft terms; products that embed or resell the database should check with legal.
Managed service and list price
MongoDB
Atlas runs on AWS, Azure and Google Cloud. Free: $0 for 512 MB. Flex: $8 to $30 per month. Dedicated: from $0.08 per hour for M10, with 2 GB of RAM. US list price as of October 2026.
MySQL
HeatWave runs on OCI, AWS and Azure: $0.0366 per ECPU hour on OCI, plus $0.04 per GB-month of storage, with a free tier. Amazon RDS for MySQL: from $0.016 per hour for db.t4g.micro (1 GiB of RAM) in US East, plus storage. US list price as of October 2026.
Price the same data set on each, since Atlas sells tiers and the MySQL services bill compute and storage separately.
Can MySQL's JSON type replace MongoDB?
For JSON that sits beside relational rows, often yes. MySQL validates JSON, indexes values through generated columns, and can update parts of a document in place. MongoDB stores the whole record as a document and has sharding built in. Test your largest documents and heaviest writes on both.
By situation
A WordPress or PHP web application
MySQL. WordPress recommends MySQL 8.0 or later, or MariaDB 10.11 or later, and PHP's mysqli extension connects to MySQL.
A product catalog with very different item types
MongoDB. Each item keeps only the fields it needs, and related data can be embedded in one document.
Orders, billing and inventory
MySQL. The data is relational, InnoDB enforces foreign keys, and SQL serves reporting directly.
Reporting on live transactional data
HeatWave adds an in-memory query accelerator to MySQL for analytics without copying data to a separate analytics database. On MongoDB, test the aggregation pipeline on your largest collections.
Quick answers
Does MySQL have a document store?
Yes. MySQL Document Store stores schema-less documents through the X DevAPI. X Plugin, which it needs, is enabled by default since MySQL 8.4.
Is MongoDB open source?
Community Server is under the SSPL, which the Open Source Initiative has not approved. Versions released before October 16, 2018 remain under AGPL v3.0.
Who owns MySQL?
Oracle, since it completed its acquisition of Sun Microsystems on January 27, 2010. Sun had acquired MySQL AB in February 2008.
Sources
- MongoDB documents
- MongoDB schema validation
- MongoDB data model design
- MongoDB $lookup
- MongoDB transactions
- MongoDB replication
- MongoDB sharding
- MongoDB 9.0 release notes
- MongoDB SSPL FAQ
- MongoDB Atlas
- MongoDB pricing
- MongoDB company
- MySQL JSON data type
- MySQL JSON_TABLE
- MySQL Document Store
- MySQL JOIN clause
- Introduction to InnoDB
- MySQL: statements that cause an implicit commit
- MySQL replication
- Introducing InnoDB Cluster
- Vitess
- MySQL commercial and GPL licensing
- About MySQL
- MySQL Community Server downloads
- MySQL HeatWave
- MySQL HeatWave pricing
- Amazon RDS for MySQL
- Amazon RDS for MySQL pricing
- WordPress requirements
- PHP MySQL Improved Extension
- Sun Microsystems Form 10-Q, acquisition of MySQL AB
- Oracle completes acquisition of Sun (Form 8-K exhibit)