Migrating MySQL to MariaDB is a dump-and-restore, not an in-place upgrade. Stand up MariaDB on a separate host or container, dump your application schemas with mysqldump --databases app_db --single-transaction --routines --triggers --events, restore with mariadb -u root < dump.sql, recreate the users and grants by hand, validate row counts and the divergent surfaces, then take a final dump and switch the connection string.
MariaDB began as a MySQL 5.1 fork in 2009 after Oracle acquired Sun (and with it, MySQL). For its first several years MariaDB was a near-drop-in replacement; the wire protocol matched, the SQL dialect was 99% the same, and the client tools were identical down to the binary name. The two have drifted apart since MySQL 5.7 / MariaDB 10.3. They're still compatible enough that the migration is mostly mechanical, but there are specific surfaces where the dialects diverge in ways that will silently corrupt your data if you don't handle them. Below is the migration I do in practice: backup with mysqldump, stand up MariaDB next to MySQL, restore, recreate the accounts, validate, swap. Plus the divergence cheat-sheet you need before you start.
How do I migrate from MySQL to MariaDB?
The supported migration is dump-and-restore, not in-place. First, run MariaDB next to the existing MySQL, on a second host or in a container, so you can verify the restore before cutting traffic. There is no built-in "parallel install" port: if both servers share a machine you choose the port yourself (3307 is the usual pick, and the one MariaDB's own documentation uses in its example) along with a separate socket and data directory. Second, take a logical dump of the application schemas with mysqldump --databases app_db --single-transaction --routines --triggers --events. Leave MySQL's mysql system schema out: its account tables are incompatible with MariaDB's. Third, restore into MariaDB with mariadb -u root < dump.sql (the MariaDB client binary; mysql is now an alias). Fourth, recreate the users and grants with CREATE USER and GRANT, then validate row counts, foreign keys, and the divergent surfaces (JSON, virtual columns, authentication plugins). Fifth, stop the application, take a final dump, restore it into MariaDB, and switch the application's database connection string. An in-place file copy from /var/lib/mysql to a MariaDB data directory often "works" for older versions but is unsupported and breaks on the system schema; always dump-and-restore.
Jump to:
- Why migrate (and why not)
- Compatibility matrix
- Where the dialects diverge
- The dump-and-restore migration
- JSON columns: the silent corruption risk
- Authentication plugin mismatch
- Replication between MySQL and MariaDB
- Validation queries
- What to do next
- FAQ
Why migrate (and why not)
The case for migrating to MariaDB:
- License clarity. MariaDB is GPLv2-only, run by the non-profit MariaDB Foundation. MySQL is owned by Oracle, dual-licensed (commercial + GPL), and the open-source posture has been less consistent over the years.
- Features MySQL doesn't have. Sequences (proper
CREATE SEQUENCE), system-versioned tables (temporal queries withAS OF), virtual columns with broader engine support, system-wide query timeout, the ColumnStore analytic engine. - Different storage engines. MariaDB ships Aria (a crash-safe MyISAM replacement), ColumnStore, MyRocks, S3 storage engine. MySQL ships InnoDB and not much else.
- Active and friendlier release cadence. MariaDB 10.5+ has had a steady minor-release cadence.
The case for staying on MySQL:
- You use MySQL-specific features that MariaDB doesn't have. Window functions and CTEs are in both, but MySQL has more polished JSON, group replication and Group Replication-based InnoDB Cluster, and the official X Protocol.
- You're on AWS Aurora. Aurora's MySQL-compatible engine is much further along than the MariaDB-compatible engine (which Amazon hasn't shipped). Migrating off Aurora is non-trivial.
- Vendor support contracts. Oracle MySQL Enterprise has audit log, transparent data encryption, thread pool, and 24/7 support. MariaDB has equivalents through MariaDB plc but the procurement path is different.
For most self-hosted MySQL installs without an active enterprise contract, MariaDB is a reasonable destination. The migration cost is the dump-restore window plus the dialect-divergence fixes below.
Compatibility matrix
| MySQL version | MariaDB version | Compatibility |
|---|---|---|
| 5.1 | MariaDB 5.1 | Binary-identical (the original fork point) |
| 5.5 | MariaDB 5.5 | Near-binary compatible |
| 5.6 | MariaDB 10.0 / 10.1 | Mostly compatible, dialect drift starts |
| 5.7 | MariaDB 10.2 / 10.3 | Compatible at the wire and SQL level, JSON is a re-implementation |
| 8.0 | MariaDB 10.5 / 10.6 / 10.11 | Compatible for most features; JSON, authentication, default_authentication_plugin diverge |
| 8.4 LTS | MariaDB 11.4 LTS | Both are current LTS; dialects close but not identical |
The general rule: pick the MariaDB version released around the same time as the MySQL version you're migrating from, or one major step later. Avoid migrating to a much older MariaDB.
Where the dialects diverge
The breaking divergences are not in the bulk of your SQL. They're in specific features. The cheat-sheet:
| Feature | MySQL | MariaDB | Action |
|---|---|---|---|
JSON data type | Binary internal format | Always stored as LONGTEXT with a JSON_VALID() CHECK constraint; JSON is just an alias for LONGTEXT, in every version | Re-test all JSON queries; the index strategies differ |
JSON_TABLE function | Yes | Added in 10.6 | If you use it, target 10.6+ |
| Virtual / generated columns | Yes, with FULLTEXT not supported on virtual | Yes, FULLTEXT supported on virtual | Move-friendly into MariaDB |
AUTHENTICATION plugin default | caching_sha2_password (8.0+) | mysql_native_password | Plan client driver impact |
default_authentication_plugin setting | Removed in 8.4 | Still works | n/a if migrating from 8.0 |
EXPLAIN ANALYZE output | Tree-based, fairly readable | Tabular, different format | Update any tooling that parses it |
INVISIBLE columns | Yes (8.0+) | Yes (10.3+) | Compatible at the SQL level, different storage |
WITH SYSTEM VERSIONING | Not available | Yes (10.3+) | MariaDB-only feature |
SEQUENCE | Not available (use AUTO_INCREMENT) | Yes (10.3+) | MariaDB-only |
INSTANT ALTER TABLE for ADD/DROP COLUMN | Yes (8.0+) | Yes (10.3+) | Compatible |
| Roles | Yes (8.0+) | Yes (10.0.5+) | Syntax slightly different |
| Group Replication / InnoDB Cluster | Yes | No (uses Galera instead) | If you depend on Group Replication, this is a no-go |
| Window functions | Yes (8.0+) | Yes (10.2+) | Compatible |
| Common Table Expressions (CTEs) | Yes (8.0+) | Yes (10.2.1+) | Compatible |
| Account storage | mysql.user is a real table with password-history and MFA columns | Accounts live in mysql.global_priv (Host, User, and a JSON Priv document); mysql.user is a view over it | Never restore MySQL's mysql schema into MariaDB; recreate accounts with CREATE USER and GRANT |
Read this table once. The two highest-impact rows for most apps are JSON and the authentication plugin. The rest are usually one-of cases.
The dump-and-restore migration
The safe procedure runs both MySQL and MariaDB side-by-side until you've validated the restore.
# 1. Dump the application schemas from MySQL. List them by name:
# do NOT use --all-databases, which also dumps MySQL's own mysql schema.
mysqldump \
--databases app_db another_db \
--single-transaction \
--routines \
--triggers \
--events \
--hex-blob \
-u root -p > mysql-to-mariadb-$(date +%Y%m%d-%H%M).sql
# 2. Stand up MariaDB where it cannot collide with MySQL.
# A second host or VM is the cleanest. On the same machine, a container works:
docker run -d --name mariadb-target \
-e MARIADB_ROOT_PASSWORD='REPLACE_WITH_A_REAL_PASSWORD' \
-p 127.0.0.1:3307:3306 \
-v mariadb-data:/var/lib/mysql \
mariadb:11.8
# 3. Restore the dump into MariaDB on port 3307
mariadb -u root -p -h 127.0.0.1 -P 3307 < mysql-to-mariadb-*.sql
# 4. Recreate users and grants (see the authentication section below)
# 5. Validate (see the validation section below)
# 6. When ready to cut over: stop the app, take a final dump,
# restore it, then switch the connection string from MySQL:3306 to MariaDB:3307.Two things in that block are deliberate.
Do not apt install mariadb-server on the host that runs MySQL. On Debian and Ubuntu the mariadb-server package conflicts with and replaces mysql-server, so installing it removes the server you are trying to migrate from. If both have to live on one machine without containers, MariaDB documents a binary-tarball install under /opt with its own my.cnf, where you set port, socket, datadir, basedir, and user explicitly. Nothing picks a second port for you.
Do not use --all-databases. It includes MySQL's mysql system schema, and MariaDB cannot take it: MariaDB keeps accounts in mysql.global_priv and exposes mysql.user as a view. Restoring an --all-databases dump from MySQL 8.4 into MariaDB 11.8 stops with ERROR 1050 (42S01): Table 'user' already exists, after it has already dropped and recreated other tables in MariaDB's mysql schema. A --databases app_db dump of the same server restores cleanly.
JSON columns: the silent corruption risk
The single most-bitten case. MySQL stores JSON in an internal binary format that preserves key order, supports fast field extraction, and is queried with operators like ->> and JSON_EXTRACT(). MariaDB stores JSON as plain LONGTEXT with a JSON_VALID() CHECK constraint. This is true in every MariaDB version, including 11.x: the JSON type is just an alias for LONGTEXT COLLATE utf8mb4_bin, never a native binary type. The on-disk representation differs from MySQL's regardless of version.
The dump-and-restore preserves the JSON text content. What it can't preserve:
- JSON object key order in MySQL is implementation-dependent; the canonical form is sorted by key. MariaDB preserves insertion order.
- JSON path indexes (the
CREATE INDEX ... ((CAST(json_col->>'$.field' AS CHAR(255)) COLLATE utf8mb4_bin))pattern) work in both but the planner uses them slightly differently. JSON_TABLEin MySQL works on 8.0.4+; in MariaDB on 10.6+.
After the restore, run every distinct JSON query the application uses against the MariaDB instance and compare results to MySQL. The cases that bite are subtle: a query that returns object keys in a particular order, or one that relies on JSON_QUOTE / JSON_UNQUOTE semantics for embedded quotes.
If your application uses MySQL-style JSON heavily and you can't easily test every path, this alone may be the reason to stay on MySQL.
Authentication plugin mismatch
Accounts do not come across in the dump, and they should not: MySQL 8.0 and later hash passwords with caching_sha2_password by default, MariaDB's default is mysql_native_password, and the two hash formats cannot be converted into each other. MariaDB's own migration guide says the same thing: the mysql.user structure is incompatible, so you re-create the users and grants on the new server.
On the MySQL side, list what exists:
SELECT user, host, plugin FROM mysql.user ORDER BY user, host;
SHOW GRANTS FOR 'app'@'%';On the MariaDB side, recreate each account with its cleartext password (which you should have in a secrets manager) and replay the grants:
CREATE USER 'app'@'%' IDENTIFIED BY 'REPLACE_WITH_THE_REAL_PASSWORD';
GRANT SELECT, INSERT, UPDATE, DELETE ON app_db.* TO 'app'@'%';Write that as a one-time user-recreation script and keep it with the migration plan. Do not try to patch mysql.global_priv by hand: it has only three columns (Host, User, Priv), the plugin and password hash are members of the JSON document in Priv, and CREATE USER, ALTER USER, and GRANT are the supported way to change them.
If you genuinely cannot recover the cleartext passwords, recent MariaDB releases ship a caching_sha2_password compatibility plugin for exactly this case: Community Server 11.4.9, 11.8.4, and 12.1 onward. It is not installed by default (INSTALL SONAME 'auth_mysql_sha2';), and MariaDB documents it as a migration aid only, so plan to move those accounts to a native MariaDB plugin afterwards.
For resetting users that you don't have the password for, the reset procedure is the same on MariaDB.
Replication between MySQL and MariaDB
For very large databases, the cleanest migration is replication: MariaDB as a replica of MySQL, then promote.
MariaDB's migration guide states that MariaDB 11.4, 11.8, and newer can replicate from a MySQL 8.0 or later primary. It comes with conditions on the MySQL side, including turning off binary log compression and certain row update event formats, so read the guide's list before you configure the source. On older MariaDB versions, treat replication from MySQL 8.0 as untested.
GTID compatibility is broken: MySQL GTIDs and MariaDB GTIDs are entirely different implementations. The MariaDB replica has to use traditional binary log file and position, with GTID explicitly disabled for that connection (MASTER_USE_GTID=no in MariaDB's CHANGE MASTER TO).
For mission-critical migrations this path is more involved than the dump-and-restore. It's mainly useful when the database is too large to dump in your maintenance window (multi-terabyte InnoDB).
Validation queries
After restore, run before cutting traffic:
-- Row counts per table, compare to a corresponding query against MySQL
SELECT table_schema, table_name, table_rows
FROM information_schema.tables
WHERE table_schema NOT IN ('mysql','sys','information_schema','performance_schema')
ORDER BY table_schema, table_name;
-- Foreign-key references
SELECT constraint_schema, constraint_name, table_name, referenced_table_name
FROM information_schema.referential_constraints
ORDER BY constraint_schema, table_name;
-- Storage engines
SELECT engine, COUNT(*) FROM information_schema.tables
WHERE table_schema NOT IN ('mysql','sys','information_schema','performance_schema')
GROUP BY engine;
-- Character sets and collations (check utf8mb4 carried over)
SELECT default_character_set_name, default_collation_name
FROM information_schema.schemata
WHERE schema_name NOT IN ('mysql','sys','information_schema','performance_schema');
-- Stored routines
SELECT routine_schema, routine_name, routine_type
FROM information_schema.routines
ORDER BY routine_schema, routine_name;table_rows from information_schema is an estimate for InnoDB. For exact counts, run SELECT COUNT(*) FROM tbl against your top tables on both sides and diff the results.
What to do next
After the cutover:
- How to Reset a Forgotten MySQL Root Password: same procedure on MariaDB.
- How to Export All MySQL Databases with mysqldump: the same tool under the
mariadb-dumpname, with a few flag differences noted there. - MySQL Cheat Sheet: the syntax is overwhelmingly the same.
- utf8 to utf8mb4 Migration in MySQL: if you haven't done it, the same procedure applies on MariaDB.
External references:
- MariaDB Knowledge Base: Migrating from MySQL
- MariaDB KB: Compatibility differences
- MariaDB system-versioned tables
FAQ
It depends on which MySQL features you use. For MySQL 5.6 and earlier the answer is essentially yes. For MySQL 5.7 the answer is "mostly, with some JSON re-testing." For MySQL 8.0 and especially 8.4 the answer is "no, expect real work."
If your application uses only standard SQL with InnoDB tables, basic indexes, and simple JSON, the migration is mechanical. If you depend on Group Replication, MySQL-specific JSON behavior, or X Protocol, MariaDB is not equivalent.
The protocol is compatible, so the same client libraries connect to both. The host/port/credentials change only if you've moved instances. The driver does not need to change for most languages: mysql2 in Node, mysqlclient in Python, JDBC mysql-connector-j, PHP mysqli / PDO_MySQL all connect to MariaDB without modification.
One exception: clients pinned to caching_sha2_password from MySQL 8.0 need to either downgrade to mysql_native_password on the MariaDB side, or use a MariaDB release that ships the caching_sha2_password compatibility plugin: Community Server 11.4.9, 11.8.4, or 12.1 and later. It is not installed by default, and MariaDB documents it for migration use only.
For a database under 100 GB, expect 1-2 hours for dump and restore plus another 1-2 hours for validation. For a multi-TB database, dump-and-restore is impractical and you should plan replication-based migration instead.
The cutover (final dump and restore, then the connection string swap) is application downtime for as long as that last dump and restore take, so time a rehearsal against your own data and schedule the cutover in a maintenance window.
InnoDB tables migrate fine through the dump, because a logical dump carries the table definitions and rows as SQL, not as files. The files themselves are not interchangeable: MySQL 8.0 and later keep metadata in a global data dictionary, MariaDB uses .frm files and its own system tables, and the two InnoDB implementations have diverged. Copying a MySQL 8 data directory or tablespace files into MariaDB is not a supported path; MariaDB's migration guide recommends export and import.
MyISAM tables migrate too, but you should convert them to InnoDB before or during the migration anyway, see MyISAM to InnoDB conversion for the procedure.
Yes, with the same dump-and-restore approach, plus the same caveats in reverse. MariaDB-specific features (system-versioned tables, sequences, ColumnStore tables) won't restore on MySQL and need to be dropped or rewritten first.
I usually recommend deciding once and not flip-flopping. The migration cost is real both directions.
WordPress runs on MariaDB unmodified. The official WordPress requirements list both MySQL and MariaDB. The wp_users table, the dbDelta schema generator, and all the standard plugins work on MariaDB the same as on MySQL.
Some hosting providers default to MariaDB now (cPanel/WHM hosts, many EU providers). If you've migrated your WordPress site recently, you may already be on MariaDB without noticing.
No. The X Protocol and MySQL's document store features (the NoSQL-style document API) are MySQL-only. If your application uses X Protocol, you cannot migrate to MariaDB.
X Protocol usage is rare in practice; most applications use the classic MySQL protocol via the standard client libraries.
If you need synchronous multi-master replication, yes. Galera (MariaDB's clustering replacement for MySQL's Group Replication) is mature, works well for read-heavy workloads, and is what most production MariaDB deployments use at scale.
For a single-instance migration, just MariaDB Server is fine. Galera adds operational complexity that should be deliberate, not a default.
Sources
Authoritative references this article was fact-checked against.
- MariaDB, JSON data type referencemariadb.com
- MariaDB, JSON_TABLE function referencemariadb.com
- MySQL 8.0, JSON_TABLE functiondev.mysql.com
- MariaDB: Bridging the Gap, MySQL to MariaDB migration guidemariadb.com
- MariaDB documentation: installing MariaDB alongside MySQLmariadb.com
- MariaDB documentation: mysql.global_priv tablemariadb.com
- MariaDB documentation: caching_sha2_password authentication pluginmariadb.com





