How can i tell if a server I'm connecting to is Percona or MySQL or MariaDB?
Is there any standard way of doing this?
I'm currently using SHOW VERSION
to test the server version, but I would also need to display the server name in the app I'm working on.
Asked
Active
Viewed 5,331 times
13

Quamis
- 10,924
- 12
- 50
- 66
2 Answers
6
You can get specific information with:
SHOW VARIABLES LIKE '%vers%'
version
and version_comment
are very specific.

tadman
- 208,517
- 23
- 234
- 262
-
1on my dev server, `version_comment=(Ubuntu)`, `version=5.5.47-0ubuntu0.14.04.1`. No trace of "MySQL" string anywhere. I've looked trhough all `SHOW VARIABLES` list and nothing relevat came up – Quamis May 19 '16 at 08:35
-
This might be distribution specific then. On Fedora I see "MySQL Community Server (GPL)" or "MariaDB Server" for the two instances I'm testing with. – tadman May 19 '16 at 08:40
-
Seems so, the example from http://dev.mysql.com/doc/refman/5.7/en/show-variables.html states `Source distribution`. – Quamis May 19 '16 at 08:54
-
Does Percona have any special variables you can pick out? – tadman May 19 '16 at 09:02
-
I don't have access to that server anymore. It was reinstalled. I would expect that the innodb_* variables to be named xtradb_*, but I wouldn't call this a clear answer to my problem. – Quamis May 19 '16 at 09:53
6
Keep in mind that "MySQL" is the original, and the others are spinoffs. Here is some code that probably always works:
version_comment REGEXP 'MariaDB' -- > Mariadb
version_comment REGEXP 'Percona' -- > Percona
else MySQL
version_comment
can be accessed via SHOW VARIABLES
or information_schema
.
@@version
is not reliable because Percona leaves no clue, although I suspect the '-30.3-' is a clue in 5.5.31-30.3-log
.
(I checked 106 servers.)
Update
(checking 264 servers.)
version REGEXP 'MariaDB' -- > Mariadb
version_comment REGEXP 'Percona' -- > Percona
else MySQL
(And we probably cannot trust for this to be the final word.)

Rick James
- 135,179
- 13
- 127
- 222
-
So I can assume that Percona & MariaDB always report their names and MySQL is acting differently here? – Quamis May 31 '16 at 15:00
-
1My answer is based on empirical evidence. Based on history... MySQL is the base product (now owned by Oracle), so it has no reason to be specific in the settings. The others are spinoffs, so they feel need for such. – Rick James May 31 '16 at 19:53
-
1A longer answer: http://stackoverflow.com/questions/43611296/how-can-i-detect-whether-connected-database-is-mariadb-or-mysql/43692813#43692813 – Rick James May 01 '17 at 15:33
-
1Be warned that this answer is probably outdated. I get version = '10.3.22-MariaDB-0+deb10u1-log', version_commnet = 'Debian 10'. See https://mariadb.com/docs/reference/mdb/system-variables/version_comment/ – Elvex Jan 21 '22 at 15:34
-
1