What command returns the current version of a MySQL database?
A 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. – mwfearnleyMar 6, 2019 at 16:44
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)
- what if I don’t want to run anything related to mysql itself? where is this version information stored? – Sajuuk Jan 18, 2018 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, 2021 at 3:27
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
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
ShareImprove this answerFollowedited Jun 26, 2019 at 10:16
- Idea here is to provide relevant information, not quick answer. Anyway, updated answer based on your suggestion. Thanks!! – Amitesh Bharti Jun 26, 2019 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, 2019 at 21:44
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
try
mysql --version
for instance. Or dpkg -l 'mysql-server*'
.
- 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 9, 2015 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 8, 2016 at 17:50 - @KolobCanyon, well, unless you don’t have it in path 🙂 – Michael Krelin – hacker Jul 8, 2016 at 20:04
- 1The command that works for the server version will presumably only work if the server is running from a Debian-installed package. – mwfearnley Mar 5, 2019 at 9:45
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)
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)
For Mac,
- login to mysql server.
- execute the following command:
SHOW VARIABLES LIKE "%version%";
- 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 4 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 |
+-----------+
Xampp with Windows users below in the command whihc worked in the mysql directory.
Use mysql -V
works fine for me on Ubuntu.
This 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.
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)
- 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, 2017 at 16:04
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.
MySQL Server version
shell> mysqld --version
MySQL Client version
shell> mysql --version
shell> mysql -V
- I see you’ve updated your answer now to include both, and put the server version first. Thanks. – mwfearnley Mar 3, 2020 at 17:13
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>
From the console you can try:
mysqladmin version -u USER -p PASSWD
For UBUNTU you can try the following command to check mysql version :
mysql --version
mysqladmin version
OR mysqladmin -V
- 1
mysqladmin version
(with appropriate connection details) will give the actual server version, butmysqladmin -V
gives the version of themysqladmin
command-line utility, which is probably not what you want. – mwfearnley Mar 5, 2019 at 9:51
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 = NUL
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
In windows ,open Command Prompt and type MySQL -V
or MySQL --version
. If you use Linux get terminal and type MySQL -v
- 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 5, 2019 at 9:54
Only this code works for me
/usr/local/mysql/bin/mysql -V
source : https://stackoverflow.com/questions/8987679/how-to-retrieve-the-current-version-of-a-mysql-database-management-system-dbms#:~:text=Go%20to%20MySQL%20workbench%20and,and%20find%20out%20the%20version.