In MySQL, we can use the sys.version_minor()
function to return the minor release version of the MySQL server.
Syntax
The syntax goes like this:
sys.version_minor()
So, no arguments are required or accepted.
Example
Here’s an example to demonstrate:
SELECT sys.version_minor();
Result:
+---------------------+ | sys.version_minor() | +---------------------+ | 0 | +---------------------+
In this case, I’m using MySQL version 8.0.29, so the sys.version_minor()
function returns 0
, because that’s the minor release part of the version.
The return value is a TINYINT UNSIGNED
value.
Get the Full Version
MySQL also has a sys.version_major()
function that returns the major release version, and a sys.version_patch()
function that returns the patch version.
There’s also a version()
function that gets the whole thing.
Here’s an example of using all of the above functions for getting the full version and also the various parts of the version:
SELECT
version() full_version,
sys.version_major() AS major,
sys.version_minor() AS minor,
sys.version_patch() AS patch;
Result:
+--------------+-------+-------+-------+ | full_version | major | minor | patch | +--------------+-------+-------+-------+ | 8.0.29 | 8 | 0 | 29 | +--------------+-------+-------+-------+
Also see 7 Ways to Check your MySQL Version for more ways to return your MySQL version.