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.
I tried
select version()
That returns only the version number and server OS information, but not the database kind.
if you are trying to do this from inside the php app you can ( which php version?) for PHP 7 use mysqli_get_server_info; or < php 7, use mysql_get_Server_info
will return
Server version: 5.5.5-10.1.23-MariaDB-9+deb9u1
php 7 http://php.net/manual/en/mysqli.get-server-info.php php 5 & < http://php.net/manual/en/function.mysql-get-server-info.php
Look in
VARIABLES
foraria_block_size
. Its existence almost certainly implies some version of MariaDB and not MySQL, nor Percona. (At least for the near future.)The beginning part of
version
:What feature are you needing? There is a chance that Percona will retrofit something from MariaDB 10.2 before it comes from MySQL.
Even when
version
is5.1.53-rel11.7-log
or5.5.35-0ubuntu0.12.04.2-log
, the first part gives you the important part of the MySQL/MariaDB/Percona version.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 always starts with
N.N.N-MariaDB
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 and Percona: 5.1, 5.5, 5.6, 5.7, 8.0
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.
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.