MySQL can handle the multiple queries; with each version, you get new revamped features. Besides, some applications require a specific MySQL version to connect the database. In that case, knowing which MySQL version you are running is beneficial. This guide presents different ways of checking your MySQL version.
How to Get the MySQL Version
It’s normal to get curious about which MySQL version you are currently running. Besides, a given MySQL version may be incompatible with your system or applications. Moreover, if you notice that you are using an outdated MySQL version, you can update to the latest one to enjoy new features and fixes for bugs.
There are different ways of checking your MySQL version.
1. Via Command Line
If you have MySQL installed on your system, you can use the -V or –version to check the MySQL version.
Note that the V is uppercase.
You will get an output which is similar to the one in the following which gives the current version of your MySQL.
2. Using MySQL Shell
You can check the MySQL version by utilizing its shell. The shell allows the users to access their databases and make queries using the command line. Use the following syntax to open the MySQL shell and use the username that you set for your MySQL. Also, you must enter your MySQL password to access it.
Once the shell opens, locate the server version as highlighted in the previous image. That’s the MySQL version that your system is currently running. You can close the shell by typing exit and pressing the enter key.
While on the MySQL shell, you can execute the various commands to get the MySQL version.
First, use the show variable query to get the version.
The version is displayed in a table format as shown in the following. Note that the version displayed is the same as that we found using other methods:
Still, you can use the SELECT query on the shell to get the MySQL version using the following command:
The query returns the version in a table format.
MySQL database has a table that contains its detail. When you query it as we previously did, you can get the various details such as the version.
Another way of running the same query is using the following command:
It returns the same output which displays the MySQL version.
Another way to get the MySQL version is by running the status command. It returns all the details about MySQL.
From the details, we can extract the version as follows:
The server version is the current version of the installed MySQL. You can also check the other details about your MySQL.
3. Using Dpkg
Depending on the distro that you are using, it’s possible to use the dpkg command to find the installed instance of the MySQL client. The output gives the version of the MySQL package that is currently installed. To use this command, list the packages and pipe the grep command to filter the MySQL-client using the following command:
In the output, note that the MySQL-client is installed and the available version is listed on the right:
There are the three easy ways of getting the MySQL version. You can list the installed packages, filter the MySQL client, use the MySQL shell, or check the version via the command line. This guide covered the three ways by giving the examples of how to use each. Hopefully, you now understand and can easily check your MySQL version.