MariaDB began as a fork of MySQL and stayed compatible for years. They have since diverged enough that moving between them is a migration rather than a swap - but for an ordinary PHP application, either runs the same schema and the same queries.

Where they differ enough to matter

  • JSON. MySQL has a real JSON type with indexing. MariaDB stores JSON as text with a check constraint - portable, and slower for anything that queries inside the document.
  • Replication. MySQL uses GTIDs, MariaDB has its own scheme. They are not interchangeable, so a replica cannot be a different one.
  • Window functions and CTEs. Both have them now; older installations of either may not.
  • Storage engines. MariaDB ships extras such as Aria and ColumnStore. Almost nobody needs them.

How to tell which you have

mysql -V\nmysql -e "SELECT VERSION()"\n# 10.x or 11.x is MariaDB; 8.x is MySQL

Moving between them

Dump and import, never a file copy. The data directories are not compatible and a copied datadir produces a database that starts and then behaves strangely, which is far worse than one that refuses to start.
mysqldump --single-transaction --routines --triggers --default-character-set=utf8mb4 db > db.sql\n# then import into the other engine and CHECK the row counts per table

Which to choose for a new site

Whichever your distribution ships and your host supports. The performance difference for a typical PHP application is inside the noise; what matters far more is the buffer pool, the indexes and the queries - see innodb_buffer_pool_size and when to add an index.

If your application documents one of them specifically, use that one. Compatibility problems are rare and are miserable when they happen.