将 PyMySQL 与 MariaDB 一起使用

2022-01-15 00:00:00 python mariadb mysql

我已阅读这篇关于从MySQL 到 Ubuntu 上的 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.

目前,我正在使用 PyMySQL 连接到我的 MySQL 数据库并插入、更新和删除值它.

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

我的问题是:我可以升级到 MariaDB 并继续使用我的 Python 代码吗?PyMySQL 也能正确连接到 MariaDB 吗?

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

推荐答案

如 MariaDB 与 MySQL - 兼容性:

出于所有实际目的,MariaDB 是替换相同 MySQL 版本的二进制文件(例如 MySQL 5.1 -> MariaDB 5.1, MariaDB 5.2 & MariaDB 5.3 是兼容的.MySQL 5.5 是与 MariaDB 5.5 兼容,并且在实践中也与 MariaDB 10.0).这意味着:

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:

  • 数据和表定义文件 (.frm) 文件是二进制兼容的.
    • 请参阅下面的说明以了解与视图不兼容的情况!
    • 您应该解决一些PHP5 的安装问题意识到(旧 PHP5 客户端如何检查库兼容性的错误).
    • There are some installation issues with PHP5 that you should be aware of (a bug in how the old PHP5 client checks library compatibility).

    这意味着在大多数情况下,您只需卸载 MySQL 和 安装 MariaDB 就可以了.(如果您使用相同的主版本,如 5.1,则无需转换任何数据文件).但是,您仍然必须运行 mysql_upgrade 才能完成升级.这是确保您的 mysql 权限和事件表使用 MariaDB 使用的新字段更新所必需的.

    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.

相关文章