如何检测连接的数据库是 MariaDB 还是 MySQL? [英] How can I detect whether connected database is MariaDB or MySQL?

查看:129
本文介绍了如何检测连接的数据库是 MariaDB 还是 MySQL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 PHP 应用程序有要求,包括MySQL 5.7+ 或 MariaDB 10.2+".我如何判断这些替代方案中的哪一个是满意的?

My PHP application has requirements, including "either MySQL 5.7+ or MariaDB 10.2+". How can I tell which of these alternatives is satisfied?

我知道如何比较版本号,也知道如何从数据库中获取版本号,但我不知道如何确定它是哪种数据库.

I know how to compare version numbers, and also to get the version number from the database, but I don't know how to determine which kind of database it is.

我试过了

select version()

这仅返回版本号和服务器操作系统信息,而不是数据库类型.

That returns only the version number and server OS information, but not the database kind.

推荐答案

VARIABLES 中查找 aria_block_size.它的存在几乎肯定意味着某个版本的 MariaDB 而不是 MySQL,也不是 Percona.(至少在不久的将来.)

Look in VARIABLES for aria_block_size. Its existence almost certainly implies some version of MariaDB and not MySQL, nor Percona. (At least for the near future.)

version开头部分:

  • 5.7"和8.0"暗示 MySQL 或 Percona;这并不意味着 MariaDB.
  • 10.2"暗示 MariaDB;MySQL 和 Percona 不太可能达到10".很长一段时间.

您需要什么功能?Percona 有可能在 MariaDB 10.2 来自 MySQL 之前对其进行改造.

What feature are you needing? There is a chance that Percona will retrofit something from MariaDB 10.2 before it comes from MySQL.

即使 version5.1.53-rel11.7-log5.5.35-0ubuntu0.12.04.2-log,第一部分介绍了 MySQL/MariaDB/Percona 版本的重要部分.

Even when version is 5.1.53-rel11.7-log or 5.5.35-0ubuntu0.12.04.2-log, the first part gives you the important part of the MySQL/MariaDB/Percona version.

Percona 版本如下所示:5.5.31-30.3-log5.6.30-76.3-56-log5.6.19-67.0-log -- 注意开头的 3 后面的额外的 2 或 3 个数字.

Percona versions look like: 5.5.31-30.3-log, 5.6.30-76.3-56-log, 5.6.19-67.0-log -- Note the extra 2 or 3 numbers after the initial 3.

MariaDB 总是以 N.N.N-MariaDB

MariaDB always starts with N.N.N-MariaDB

Oracle 的 MySQL 以 NNN 开头,但可能会继续使用 -enterprise(付费版)、-community(免费版)、-0ubuntu0(Ubuntu移植)、-Debian

Oracle's MySQL starts with N.N.N, but might continue with -enterprise (paid version), -community (free version), -0ubuntu0 (ported by Ubuntu), -Debian, etc.

MariaDB:5.1、5.2、5.3、5.4、5.5、10.0、10.1、10.2、10.3、10.4、10.5
Oracle 和 Percona:5.1、5.5、5.6、5.7、8.0

MariaDB: 5.1, 5.2, 5.3, 5.4, 5.5, 10.0, 10.1, 10.2, 10.3, 10.4, 10.5
Oracle and Percona: 5.1, 5.5, 5.6, 5.7, 8.0

8.0 周期才刚刚开始.这意味着 5.6 将很快关闭,而 5.7 还剩下一些生命,但不会有太多新的东西.

The 8.0 cycle is just beginning. This means that 5.6 will soon be closing down and 5.7 has some life left, but not much new will be but in it.

澄清什么是主要";发布.
对于 MySQL(和 Percona),这些是主要的",它们不是连续':5.1、5.5、5.6、5.7、8.0.
对于 MariaDB:5.1、5.2、5.3、5.4、5.5、10.0、10.1、10.2、10.3、10.4、10.5.

Clarification of what is a "major" release.
For MySQL (and Percona), these are "major", and they are not consecutive': 5.1, 5.5, 5.6, 5.7, 8.0.
For MariaDB: 5.1, 5.2, 5.3, 5.4, 5.5, 10.0, 10.1, 10.2, 10.3, 10.4, 10.5.

这篇关于如何检测连接的数据库是 MariaDB 还是 MySQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆