我的PHP应用程序有要求,包括“ MySQL 5.7+或MariaDB 10.2 + ”。如何判断哪些替代品满意?
我知道如何比较版本号,以及从数据库中获取版本号,但我不知道如何确定它是哪种数据库。
我试过
select version()
只返回版本号和服务器操作系统信息,但不返回数据库类型。
答案 0 :(得分:1)
在VARIABLES
中查找aria_block_size
。它的存在几乎肯定意味着某些版本的MariaDB和不是 MySQL,也不是Percona。 (至少在不久的将来。)
version
的开头部分:
您需要什么功能? Percona有可能在它来自MySQL之前从MariaDB 10.2中改进一些东西。
即使version
为5.1.53-rel11.7-log
或5.5.35-0ubuntu0.12.04.2-log
,第一部分也会为您提供MySQL / MariaDB / Percona版本的重要部分。
Percona版本如下:5.5.31-30.3-log
,5.6.30-76.3-56-log
,5.6.19-67.0-log
- 请注意最初3之后的额外2或3个数字。
MariaDB始终以N.N.N-MariaDB
Oracle的MySQL以N.N.N
开头,但可以继续-enterprise
(付费版),-community
(免费版),-0ubuntu0
(由Ubuntu移植) ),-Debian
等
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
8.0周期刚刚开始。这意味着5.6将很快关闭,5.7还剩下一些生命,但不会有太多新的东西,但是在其中。
澄清什么是"主要"释放。
对于MySQL(和Percona),这些是" major",而它们不是
连续':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。
答案 1 :(得分:0)
countSwap
答案 2 :(得分:0)
如果你想从php应用程序中做到这一点你可以( 哪个php版本?)for PHP 7使用mysqli_get_server_info;或者< php 7,使用mysql_get_Server_info
<?php
$link = mysqli_connect("localhost", "my_user", "my_password");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* print server version */
printf("Server version: %s\n", mysqli_get_server_info($link));
/* close connection */
mysqli_close($link);
?>
将返回
服务器版本:5.5.5-10.1.23- MariaDB -9 + deb9u1
php 7 http://php.net/manual/en/mysqli.get-server-info.php php 5&amp; &LT; http://php.net/manual/en/function.mysql-get-server-info.php