如何检索MySQL数据库的当前版本?

什么命令返回当前版本的MySQL数据库?

试试这个function –

SELECT VERSION(); 

版()

或者更多细节使用:

 SHOW VARIABLES LIKE "%version%"; 

MySql – 确定版本

尝试

 mysql --version 

例如。 或者dpkg -l 'mysql-server*'

对于UBUNTU,您可以尝试以下命令来检查mysql版本:

 mysql --version 

mysqladmin version或者mysqladmin -V

我find了一个简单的方法来获得这个。

例如:Unix命令(这样你不需要2个命令)

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

示例输出:

 +-------------------------+-------------------------+ | 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 | +-------------------------+-------------------------+ 

在以上情况下,mysql版本是5.5.49

请find这个有用的参考 。

SHOW VARIABLES LIKE "%version%";

确定你当前的MySQL版本

 shell> mysql --version shell> mysql -V 

在Ubuntu上使用mysql -V可以正常工作

从控制台你可以尝试:

 mysqladmin version -u USER -p PASSWD 

只需使用login到Mysql

 mysql -u root -p 

然后input这个命令

 select @@version; 

这会给出结果,

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

login到你的mysql,复制并粘贴这个:

 SHOW VARIABLES LIKE "%version%"; 

示例输出:

  mysql> SHOW VARIABLES LIKE "%version%"; +-------------------------+---------------------+ | Variable_name | Value | +-------------------------+---------------------+ | protocol_version | 10 | | version | 5.1.73 | | version_comment | Source distribution | | version_compile_machine | i386 | | version_compile_os | redhat-linux-gnu | +-------------------------+---------------------+ 5 rows in set (0.00 sec) 

在Ubuntu和其他Linux varian, SELECT @@version上试过这个,工作得很好。

当您第一次login时,您也可以查看MySQL shell的顶部。它实际上在那里显示版本。

 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> 
 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) 

用CLI在一行中:

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

要么

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

返回这样的东西:

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