首页 文章

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

提问于
浏览
310

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

18 回答

  • 9

    试试这个功能 -

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

    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

  • 7

    尝试

    mysql --version
    

    例如 . 或 dpkg -l 'mysql-server*' .

  • 2

    在Ubuntu上使用 mysql -V 对我来说很好用 .

  • 4

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

    mysql --version
    
  • 15

    我发现了一种简单的方法 .

    示例: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 .

    请找this useful reference .

  • 1
    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

  • 9
    shell> mysql --version
    
    shell> mysql -V
    
  • 1

    mysqladmin versionmysqladmin -V

  • 14

    从控制台你可以尝试:

    mysqladmin version -u USER -p PASSWD
    
  • 1

    只需登录Mysql即可

    mysql -u root -p
    

    然后输入此命令

    select @@version;
    

    这将给出结果,

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

    登录到你的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)
    
  • 530

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

    您还可以在首次登录时查看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>
    
  • 14

    在Ubuntu和其他linux varian上试过这个, SELECT @@version 并且运行得很好 .

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

    在windows中,获取cmd并键入MySQL -V或MySQL --version

    如果你使用Linux获取终端并输入MySQL -v

  • 1

    Mysql客户端版本:

    Mysql -version
    

    Mysql服务器版:有很多方法可以找到

    • SELECT version();

    enter image description here

    • SHOW VARIABLES LIKE "%version%";

    enter image description here

  • 162

    对于Mac,

    • 登录mysql服务器 .

    • 执行以下命令:

    SHOW VARIABLES LIKE "%version%";
    

相关问题