-2

I maintain an opensource project that supports multiple database backends. Users can either MySQL, MariaDB, Postgres etc..

There is a variation in behaviour between MySQL and MariaDB and I need to determine which database server is in use.

Given a MySQL connection only: how can I determine which MySQL server flavor I am talking to? MySQL or MariaDB? Is there a magic SQL query?

Note: select version(); does not provide any info on whether we are speaking with a MySQL or MariaDB server.

E_net4
  • 27,810
  • 13
  • 101
  • 139

1 Answers1

1
show variables like 'version%';

MySQL: https://dbfiddle.uk/jiksphR2

Variable_name Value
version 8.0.30
version_comment MySQL Community Server - GPL

MariaDB: https://dbfiddle.uk/o_jYif0i

Variable_name Value
version 10.6.9-MariaDB-1:10.6.9+maria~deb11
version_comment mariadb.org binary distribution

There are additional version variables for the OS, the architecture, and so on, but these two above are the most relevant.

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828