JNevens
JNevens

Reputation: 12002

Using PyMySQL with MariaDB

I have read this article about switching from MySQL to MariaDB on Ubuntu. The article claims that it would be not problem to switch between the two.

Currently, I am using PyMySQL to connect to my MySQL database and insert, update and delete values from it.

My question is: can I just upgrade to MariaDB and keep on using my Python code? Will PyMySQL also connect correctly to MariaDB?

Upvotes: 0

Views: 6719

Answers (1)

eggyal
eggyal

Reputation: 125955

As documented under MariaDB versus MySQL - Compatibility:

MariaDB is a binary drop in replacement for MySQL

For all practical purposes, MariaDB is a binary drop in replacement of the same MySQL version (for example MySQL 5.1 -> MariaDB 5.1, MariaDB 5.2 & MariaDB 5.3 are compatible. MySQL 5.5 is compatible with MariaDB 5.5 and also in practice with MariaDB 10.0). What this means is that:

  • Data and table definition files (.frm) files are binary compatible.
    • See note below for an incompatibility with views!
  • All client APIs, protocols and structs are identical.
  • All filenames, binaries, paths, ports, sockets, and etc... should be the same.
  • All MySQL connectors (PHP, Perl, Python, Java, .NET, MyODBC, Ruby, MySQL C connector etc) work unchanged with MariaDB.
  • The mysql-client package also works with MariaDB server.
  • The shared client library is binary compatible with MySQL's client library.

This means that for most cases, you can just uninstall MySQL and install MariaDB and you are good to go. (No need to convert any datafiles if you use same main version, like 5.1). You must however still run mysql_upgrade to finish the upgrade. This is needed to ensure that your mysql privilege and event tables are updated with the new fields MariaDB uses.

The article goes on to list a few minor incompatibilities, which you should check your application(s) do not rely upon.

Upvotes: 3

Related Questions