Search code examples
mysqlmariadbpercona

determine if mysql or percona or mariaDB


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.


Solution

  • 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.)