How to Get Version in MySQL

Preet Sanghavi Feb 02, 2024
How to Get Version in MySQL

In this tutorial, we will learn how to fetch the current version of MySQL in a Windows system.

It becomes necessary for businesses to maintain versions of different tools and software used to run the business to maintain system compatibility. It is also true for MySQL. Ensuring version similarity can help prevent bugs.

MySQL assists us with a predefined function that can help us fetch the MySQL server version. Let us understand how to run this function and get the version in greater depth. To get the current version of MySQL on your system, one can use the following query.

SELECT VERSION();

It would result in the version being displayed on the MySQL client. The output can be illustrated as follows.

VERSION()
8.0.27

We can also use an alias to showcase the version with increased readability for the user or the client. It can be done with the help of the following query.

SELECT VERSION() as your_sql_version;

The output of the query above can be illustrated as follows.

your_sql_version
8.0.27
Note
In the code above, we use the alias your_sql_version for better readability with the AS keyword in MySQL.

One can also use the query below to fetch the version alternatively.

select @@version

This query would also result in an output illustrated as follows.

@@version
8.0.27

Thus, with the help of the VERSION() function or @@version statement, we can efficiently fetch the version of MySQL.

Preet Sanghavi avatar Preet Sanghavi avatar

Preet writes his thoughts about programming in a simplified manner to help others learn better. With thorough research, his articles offer descriptive and easy to understand solutions.

LinkedIn GitHub

Related Article - MySQL Version