In this tutorial, we will look at how to check the version of the MySQL server that is running on a system. Different versions of MySQL behave differently and also have different features so it is important to know what version is running for compatibility reasons.
There are 3 basic ways of checking the MySQL version. We can do it from the command line without logging in to the server, or we can do it in 2 ways (using SQL queries) after logging in to the server.
After logging in to the MySQL server, execute:
SHOW VARIABLES LIKE '%version%';
Expect something like:
+-------------------------+---------------------+ | Variable_name | Value | +-------------------------+---------------------+ | protocol_version | 10 | | version | 5.1.41-3ubuntu12.10 | | version_comment | (Ubuntu) | | version_compile_machine | i486 | | version_compile_os | debian-linux-gnu | +-------------------------+---------------------+
We could use another SQL query to get the current MySQL version:
SELECT VERSION();
Expect something like:
+---------------------+ | VERSION() | +---------------------+ | 5.1.41-3ubuntu12.10 | +---------------------+ 1 row in set (0.00 sec)
We can also check our version of MySQL without logging in to the MySQL server. From the command line (in Ubuntu Linux for example) we can execute:
mysql -V
The result would be something like this:
The most accurate way to check the MySQL version is to use SQL queries from within the MySQL server itself. That is because the MySQL client which we check the version of from the command line may have a different version from the actual MySQL server.
We hope this MySQL tutorial was helpful.