What command returns the current version of a MySQL database?
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 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
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
In windows ,open Command Prompt and type MySQL -V
or MySQL --version
. If you use Linux get terminal and type MySQL -v
Only this code works for me
/usr/local/mysql/bin/mysql -V
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