Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you tell the difference between MariaDB and MySQL from a PHP script?

Tags:

php

mysql

mariadb

Is there any way to detect whether it's MySQL being used or MariaDB being used? As this would be useful in making MariaDB specific optimizations.

like image 472
Azareal Avatar asked Feb 09 '14 19:02

Azareal


1 Answers

SHOW VARIABLES LIKE "%version%";

This is from Maria DB

version=10.0.7-MariaDB-1~quantal-log

This is from MySQL

version_comment=MySQL Community Server (GPL)

With PDO you can use ATTR_SERVER_VERSION attribute to get server version:

echo $conn->getAttribute(PDO::ATTR_SERVER_VERSION); // output: <major>.<minor>.<build>-MariaDB
like image 200
bumperbox Avatar answered Sep 16 '22 22:09

bumperbox