How to retrieve the current version of a MySQL database management system (DBMS)?

Mysql

Mysql Problem Overview


What command returns the current version of a MySQL database?

Mysql Solutions


Solution 1 - Mysql

Try this function -

SELECT VERSION();
-> '5.7.22-standard'

VERSION()

Or for more details use :

SHOW VARIABLES LIKE "%version%";
+-------------------------+------------------------------------------+
| Variable_name           | Value                                    |
+-------------------------+------------------------------------------+
| protocol_version        | 10                                       |
| version                 | 5.0.27-standard                          |
| version_comment         | MySQL Community Edition - Standard (GPL) |
| version_compile_machine | i686                                     |
| version_compile_os      | pc-linux-gnu                             |
+-------------------------+------------------------------------------+
5 rows in set (0.04 sec)

MySQL 5.0 Reference Manual (pdf) - Determining Your Current MySQL Version - page 42

Solution 2 - Mysql

Many answers suggest to use mysql --version. But the mysql programm is the client. The server is mysqld. So the command should be

mysqld --version

or

mysqld --help

That works for me on Debian and Windows.

When connected to a MySQL server with a client you can use

select version()

or

select @@version

Solution 3 - Mysql

try

mysql --version

for instance. Or dpkg -l 'mysql-server*'.

Solution 4 - Mysql

Use mysql -V works fine for me on Ubuntu.

Solution 5 - Mysql

Mysql Client version : Please beware this doesn't returns server version, this gives mysql client utility version

mysql -version 

Mysql server version : There are many ways to find

  1. SELECT version();

enter image description here

  1. SHOW VARIABLES LIKE "%version%";

enter image description here

  1. mysqld --version

Solution 6 - Mysql

SHOW VARIABLES LIKE "%version%";
+-------------------------+------------------------------------------+
| Variable_name           | Value                                    |
+-------------------------+------------------------------------------+
| protocol_version        | 10                                       |
| version                 | 5.0.27-standard                          |
| version_comment         | MySQL Community Edition - Standard (GPL) |
| version_compile_machine | i686                                     |
| version_compile_os      | pc-linux-gnu                             |
+-------------------------+------------------------------------------+
5 rows in set (0.04 sec)

MySQL 5.0 Reference Manual (pdf) - Determining Your Current MySQL Version - page 42

Solution 7 - Mysql

I found a easy way to get that.

Example: Unix command(this way you don't need 2 commands.),

$ mysql -u root -p -e 'SHOW VARIABLES LIKE "%version%";'

Sample outputs:

+-------------------------+-------------------------+
| Variable_name           | Value                   |
+-------------------------+-------------------------+
| innodb_version          | 5.5.49                  |
| protocol_version        | 10                      |
| slave_type_conversions  |                         |
| version                 | 5.5.49-0ubuntu0.14.04.1 |
| version_comment         | (Ubuntu)                |
| version_compile_machine | x86_64                  |
| version_compile_os      | debian-linux-gnu        |
+-------------------------+-------------------------+

In above case mysql version is 5.5.49.

Please find this useful reference.

Solution 8 - Mysql

For UBUNTU you can try the following command to check mysql version :

mysql --version

Solution 9 - Mysql

Simply login to the Mysql with

mysql -u root -p

Then type in this command

select @@version;

This will give the result as,

+-------------------------+
| @@version               |
+-------------------------+
| 5.7.16-0ubuntu0.16.04.1 |
+-------------------------+
1 row in set (0.00 sec)

Solution 10 - Mysql

Go to MySQL workbench and log to the server. There is a field called Server Status under MANAGEMENT. Click on Server Status and find out the version. enter image description here

Or else go to following location and open cmd -> C:\Windows\System32\cmd.exe. Then hit the command -> mysql -V

enter image description here

Solution 11 - Mysql

MySQL Server version

shell> mysqld --version

MySQL Client version

shell> mysql --version

shell> mysql -V 

Solution 12 - Mysql

mysqladmin version OR mysqladmin -V

Solution 13 - Mysql

From the console you can try:

mysqladmin version -u USER -p PASSWD

Solution 14 - Mysql

With CLI in one line :

mysql --user=root --password=pass --host=localhost db_name --execute='select version()';

or

mysql -uroot -ppass -hlocalhost db_name -e 'select version()';

return something like this :

+-----------+
| version() |
+-----------+
| 5.6.34    |
+-----------+

Solution 15 - Mysql

For Mac,

  1. login to mysql server.

  2. execute the following command:

      SHOW VARIABLES LIKE "%version%";
    

Solution 16 - Mysql

You can also look at the top of the MySQL shell when you first log in. It actually shows the version right there.

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 67971
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Solution 17 - Mysql

E:\>mysql -u root -p
Enter password: *******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1026
Server version: 5.6.34-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select @@version;
+------------+
| @@version  |
+------------+
| 5.6.34-log |
+------------+
1 row in set (0.00 sec)

Solution 18 - Mysql

Xampp with Windows users below in the command whihc worked in the mysql directory. enter image description here

Solution 19 - Mysql

In windows ,open Command Prompt and type MySQL -V or MySQL --version. If you use Linux get terminal and type MySQL -v

Solution 20 - Mysql

Sometimes it is important to know which version of MySQL candidate is available to installed by default. here is the little command to check that prior to actually installing.

sudo apt-cache policy mysql-server

This is more important for any existing project which might be running on old MySQL Versions e.g. 5.7.

A sample output of the above command could be:

> mysql-server: Installed: (none) Candidate: > 8.0.29-0ubuntu0.20.04.3 Version table: > 8.0.29-0ubuntu0.20.04.3 500 > > 500 http://mirrors.digitalocean.com/ubuntu focal-updates/main amd64 > Packages 500 http://security.ubuntu.com/ubuntu focal-security/main > amd64 Packages > 8.0.19-0ubuntu5 500 > > 500 http://mirrors.digitalocean.com/ubuntu focal/main amd64 Packages

This states that by default by running the following command some flavour of MySQL Server 8 will be installed.

sudo apt install mysql-server

Solution 21 - Mysql

Here two more methods:

Linux: Mysql view version: from PHP

From a PHP function, we can see the version used:

mysql_get_server_info ([resource $ link_identifier = NULL]): string

Linux: Mysql view version: Package version

For RedHat / CentOS operating systems:

rpm -qa | grep mysql

For Debian / Ubuntu operating systems:

rpm -qa | grep mysql

Extracted from: https://www.sysadmit.com/2019/03/linux-mysql-ver-version.html

Solution 22 - Mysql

Only this code works for me

/usr/local/mysql/bin/mysql -V  

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionpheromixView Question on Stackoverflow
Solution 1 - MysqlDevartView Answer on Stackoverflow
Solution 2 - MysqlPaul SpiegelView Answer on Stackoverflow
Solution 3 - MysqlMichael Krelin - hackerView Answer on Stackoverflow
Solution 4 - MysqlUmesh KaushikView Answer on Stackoverflow
Solution 5 - MysqlAmitesh BhartiView Answer on Stackoverflow
Solution 6 - MysqlJohn WooView Answer on Stackoverflow
Solution 7 - Mysqltk_View Answer on Stackoverflow
Solution 8 - MysqlMuhammad waqas muneerView Answer on Stackoverflow
Solution 9 - MysqlNirojan SelvanathanView Answer on Stackoverflow
Solution 10 - MysqlSandun SusanthaView Answer on Stackoverflow
Solution 11 - MysqlNanhe KumarView Answer on Stackoverflow
Solution 12 - MysqlSingh AnujView Answer on Stackoverflow
Solution 13 - MysqlspikeView Answer on Stackoverflow
Solution 14 - MysqlNolwennigView Answer on Stackoverflow
Solution 15 - MysqlKayVView Answer on Stackoverflow
Solution 16 - MysqlDavid DugginsView Answer on Stackoverflow
Solution 17 - MysqlAbhay SinghView Answer on Stackoverflow
Solution 18 - MysqlAmol Bhandari SJView Answer on Stackoverflow
Solution 19 - MysqlManjitha TesharaView Answer on Stackoverflow
Solution 20 - MysqlDibyendu Mitra RoyView Answer on Stackoverflow
Solution 21 - MysqlJohn ElvialView Answer on Stackoverflow
Solution 22 - MysqlKuhanView Answer on Stackoverflow