PostgreSQL vs MySQL, a comparison
By Flavio Copes
A comparison of PostgreSQL and MySQL covering their licenses, the MariaDB fork, feature parity, and ACID compliance, to help you pick one to use.
In this post I want to make a high-level comparison of PostgreSQL and MySQL.
Both are relational database management systems: a server process owns the data, and your application connects to it and sends SQL. The differences are in the details, and for most projects the details matter less than people think.
Licensing
One of the main selling points of PostgreSQL is the license. PostgreSQL is Open Source under the PostgreSQL License, a permissive license similar to BSD and MIT, and it is owned by the PostgreSQL Global Development Group community. You can use it, modify it, and embed it in commercial products without restrictions.
MySQL today is owned by Oracle, and it has two different licenses. One is open source (GPL), the other one is commercial. This does not mean that if you want to use MySQL for a commercial project you need to pay. Running your application against MySQL is fine. The commercial license provides paid support and additional software built on top of MySQL, from Oracle.
There is a fully Open Source fork of MySQL called MariaDB, which is much less popular in terms of usage and branding, because it does not have the same history of MySQL, but it’s an optimal drop-in replacement if you prefer MySQL but you are worried about licensing.
Features
More or less, the feature set of both MySQL and PostgreSQL is equivalent. One might do something that the other does not, but we’re talking about advanced features that most applications never touch.
Both are very advanced database management systems with a long history.
Both support the SQL standard (not completely, but a large portion) and add features on top of it. Both provide ACID (Atomicity, Consistency, Isolation, Durability) compliance.
Both allow you to easily create replication, both are very secure, and both have a huge community around them for any problem you might have.
Both have a large set of tooling built around them.
Which one should you choose?
It’s hard to give a universal answer.
I built a free Postgres vs SQLite vs MySQL comparison tool that puts the three side by side and helps you pick based on your project.
Unless you need one particular feature implemented in one and not implemented in the other, my advice is to choose the one you are already familiar with.
For example, if you come from WordPress and have interacted with MySQL before, you can just stick to it (or MariaDB).
It might also depend on the platform you want to deploy your software on. Many hosting platforms provide a managed PostgreSQL database as a service, some offer managed MySQL, and using the database your platform manages for you is often more convenient than running your own database server.
Related posts about database: