What command returns the current version of a MySQL database?
-
28A surprising number of answers below suggest some variant of `mysql --version`. This gives the version of the **client** utility, not the server, so it's a bit like trying to find out your version of Apache by loading Firefox and opening the Help->About dialog. – mwfearnley Mar 06 '19 at 16:44
23 Answers
Try this function -
SELECT VERSION();
-> '5.7.22-standard'
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
-
1http://dev.mysql.com/doc/refman/5.0/en/installation-version.html is a 404. – Funk Forty Niner Nov 22 '16 at 15:58
-
what if I don't want to run anything related to mysql itself? where is this version information stored? – Sajuuk Jan 18 '18 at 13:25
-
@Sajuuk it isn't stored anywhere. but if you are using some kind of packaging system, that will store the version – ysth Jan 11 '21 at 03:27
-
This is instant solution. I got it on first click. It should be the accepted answer. – kishor10d Jul 20 '22 at 08:20
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

- 30,925
- 5
- 44
- 53
try
mysql --version
for instance. Or dpkg -l 'mysql-server*'
.

- 138,757
- 24
- 193
- 173
-
1This is the best quick option if you're lazy - you don't even need to log in `:-D` works fine on Centos / RHEL command line as well as Ubuntu. – user56reinstatemonica8 Dec 09 '15 at 10:39
-
13@user568458, admittedly, though, it gives you the client's version or the version of local server provided that the one that is installed as a package is running ;) – Michael Krelin - hacker Dec 09 '15 at 13:57
-
The command `mysql --version` is not OS specific. This will work on any Linux distro, Windows and OS X. – Kellen Stuart Jul 08 '16 at 17:50
-
@KolobCanyon, well, unless you don't have it in path :) – Michael Krelin - hacker Jul 08 '16 at 20:04
-
@MichaelKrelin-hacker Right! Worth mentioning as well that editing the environment variables, including the `$PATH` variable ***IS*** OS specific. – Kellen Stuart Jul 09 '16 at 13:25
-
It says - mysql Ver 15.1 Distrib 10.1.19-MariaDB, for Win32 (AMD64). Ok, its maria db and not really mysql, thanks to my xampp installation. I am confused. What does that ver 15.1 mean ? – MasterJoe Jan 20 '17 at 00:08
-
@testerjoe2, it's mariadb version, not sure how it corresponds with mysql versions. – Michael Krelin - hacker Jan 20 '17 at 07:56
-
1The command that works for the server version will presumably only work if the server is running from a Debian-installed package. – mwfearnley Mar 05 '19 at 09:45
-
Use mysql -V
works fine for me on Ubuntu.

- 1,613
- 24
- 29

- 1,551
- 1
- 16
- 18
-
5This gives the version of the `mysql` client utility. This *might* be a similar version if it's installed on the same system as the server, but if they're on different systems, it could be completely different. – mwfearnley Mar 05 '19 at 09:47
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
SELECT version();
SHOW VARIABLES LIKE "%version%";
mysqld --version

- 14,264
- 6
- 62
- 62
-
The `mysql` command needs to be lower case for most non-Windows platforms. But also, it would be better not to open your answer with the MySQL *client* version, because it's not what's asked for, and could mislead people. – mwfearnley Jun 26 '19 at 07:59
-
Idea here is to provide relevant information, not quick answer. Anyway, updated answer based on your suggestion. Thanks!! – Amitesh Bharti Jun 26 '19 at 10:23
-
Hi, thanks for listening to my feedback. I would still remove the client info, because it’s not relevant (although it is tangentially related). And at the least I’d recommend opening with the “server version” info. Your warning is helpful though. – mwfearnley Jun 27 '19 at 21:44
-
-
It already has queries in the text format which is easy to copy. – Amitesh Bharti Dec 27 '22 at 14:43
-
In contrast to screenshots (speak: pictures) text cannot vanish over time. Being able to copy output text is an advantage for everybody who cannot reproduce it with the same query/command for many reasons. And you could have indented the output (screenshots) as per your numbered list. And point out what's SQL and what's shell. – AmigoJack Dec 28 '22 at 21:54
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
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.
Or else go to following location and open cmd -> C:\Windows\System32\cmd.exe. Then hit the command -> mysql -V

- 1,010
- 1
- 10
- 11
-
1Note that you get to the 'Management' window by clicking on 'Administration' (rather than 'Schemas') in the tabs at the bottom of the 'Navigator' window on the left. – Barry DeCicco Mar 16 '21 at 17:47
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.

- 16,415
- 8
- 80
- 90
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)

- 10,066
- 5
- 61
- 82
For UBUNTU you can try the following command to check mysql version :
mysql --version

- 3,740
- 3
- 27
- 53

- 205
- 2
- 3
MySQL Server version
shell> mysqld --version
MySQL Client version
shell> mysql --version
shell> mysql -V

- 15,498
- 5
- 79
- 71
-
5These give the version of the `mysql` client utility, which may be completely different from the version the database server is running. – mwfearnley Mar 05 '19 at 09:48
-
I see you've updated your answer now to include both, and put the server version first. Thanks. – mwfearnley Mar 03 '20 at 17:13
mysqladmin version
OR mysqladmin -V

- 9,534
- 2
- 23
- 35

- 99
- 1
- 1
-
2
-
1`mysqladmin version` (with appropriate connection details) will give the actual server version, but `mysqladmin -V` gives the version of the `mysqladmin` command-line utility, which is probably not what you want. – mwfearnley Mar 05 '19 at 09:51
For Mac,
login to mysql server.
execute the following command:
SHOW VARIABLES LIKE "%version%";

- 12,987
- 11
- 98
- 148
-
2This should work in a MySQL client on any platform. It's the same solution given in an earlier answer: https://stackoverflow.com/a/8987742/446106 – mwfearnley Jun 18 '19 at 11:59
-
This worked for me from Datagrip, and as mentioned earlier, should work from any mysql client, because it is a db query, it is not os dependant so far I understand. – Codigo Morsa Feb 04 '22 at 10:16
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 |
+-----------+

- 1,613
- 24
- 29
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>

- 331
- 2
- 4
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)

- 63,369
- 21
- 118
- 128

- 49
- 1
-
Could you please provide some context to your answer. Though its clear this shows a solution, some explanation as to your approach and why its a good method would be helpful. Generally just posting code chunks is frowned on in SO. – Single Entity Apr 19 '17 at 10:34
-
4I don't think any explanation is needed for why `SELECT @@version;`, which shows the version, would be a good method for showing the version. The bigger issue IMO is that this answer is a duplicate of earlier answers. – Matthew Read Sep 25 '17 at 16:04
In windows ,open Command Prompt and type MySQL -V
or MySQL --version
. If you use Linux get terminal and type MySQL -v

- 2,067
- 2
- 28
- 31

- 562
- 2
- 8
- 21
-
-
3This is only for the MySQL client, which may be very different from the sever. Also, the Linux command would need to be lower case. – mwfearnley Mar 05 '19 at 09:54
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

- 1,604
- 22
- 20
Print a Dockerized MariaDB/MySQL Server version:
When I backup a WordPress site- in this case containerized- I capture the WordPress version in the filename as well as the DB version that was current at the time of the backup. This ensures that if I ever needed to restore, I wouldn't have a compatibility nightmare figuring out what version DB works with a specified version of the WordPress backup.
So I include the DB server version in the dump name. I loaded the below into a self-populating variable:
docker exec -it ContainerIdOfDB mysqld --version | awk '{print $3}' | cut -d'-' -f1
This pukes out the current DB version without having to login to retrieve it.

- 3,580
- 3
- 25
- 24
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

- 11
Only this code works for me
/usr/local/mysql/bin/mysql -V

- 495
- 7
- 17
-
That returns the version number of the **client**, not of the server – Nico Haase Feb 28 '20 at 16:00