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

查看:1793
本文介绍了如何检测连接的数据库是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的某些版本,以及 not 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有可能在从MySQL升级到MariaDB 10.2之前对其进行改造.

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以N.N.N开头,但可能以-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
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
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(和Per​​cona),这些是主要",而它们不是 连续":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.

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.

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

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