哪个命令返回MySQL数据库的当前版本?


试试这个功能-

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

(版本)

或更多细节使用:

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参考手册(pdf) -确定您当前的MySQL版本-第42页


try

mysql --version

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


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参考手册(pdf) -确定您当前的MySQL版本-第42页


从控制台你可以尝试:

mysqladmin version -u USER -p PASSWD

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

mysql --version

MySQL服务器版本

shell> mysqld --version

MySQL客户端版本

shell> mysql --version

shell> mysql -V 


mysqladmin版本或mysqladmin -V


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


我找到了一个简单的方法。

例如: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。

请找到这份有用的参考资料。


您还可以在第一次登录时查看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>

简单的登录到Mysql用

mysql -u root -p

然后输入这个命令

select @@version;

得到的结果是,

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

用CLI一行:

Mysql——user=root——password=pass——host=localhost db_name——execute='select version()';

or

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

返回如下内容:

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

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)

对于Mac,

登录mysql服务器。 执行如下命令: 显示变量“%版本%”;


在windows下,打开命令提示符,输入MySQL -V或MySQL——version。如果您使用Linux get终端并输入MySQL -v


Mysql客户端版本:请注意,这不会返回服务器版本,这提供了Mysql客户端实用版本

mysql -version 

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

选择版本();

显示变量“%版本%”;

mysqld——版本


很多答案建议使用mysql——version。但是mysql程序是客户端。服务器为mysqld。所以命令应该是

mysqld --version

or

mysqld --help

这在Debian和Windows上都适用。

当你用客户端连接到MySQL服务器时,你可以使用

select version()

or

select @@version

这里还有两个方法:

Linux: Mysql视图版本:从PHP

从PHP函数中,我们可以看到使用的版本:

mysql_get_server_info ([resource $ link_identifier = NULL]): string

Linux: Mysql view version:包的版本号

对于RedHat / CentOS操作系统:

rpm -qa | grep mysql

对于Debian / Ubuntu操作系统:

rpm -qa | grep mysql

摘自:https://www.sysadmit.com/2019/03/linux-mysql-ver-version.html


只有这个代码对我有用

/usr/local/mysql/bin/mysql -V  

转到MySQL工作台并登录到服务器。在MANAGEMENT下有一个名为Server Status的字段。单击Server Status并查找版本。

或者转到以下位置,打开cmd -> c:\ windows \ system32 \cmd.exe然后点击命令-> mysql - v


Xampp与Windows用户在下面的命令中工作在mysql目录。


有时候,知道默认安装的MySQL候选版本是可用的是很重要的。下面是在实际安装之前检查的小命令。

sudo apt-cache policy mysql-server

这对于任何可能运行在旧MySQL版本(如5.7)上的现有项目都更重要。

上面命令的示例输出可以是:

mysql-server: Installed:(none) 8.0.29-0ubuntu0.20.04.3版本表: 8.0.29-0ubuntu0.20.04.3 500 500 http://mirrors.digitalocean.com/ubuntu focal-updates/main amd64 软件包500 http://security.ubuntu.com/ubuntu focus -security/main amd64包 8.0.19-0ubuntu5 500 500 http://mirrors.digitalocean.com/ubuntu focal/main amd64包

这说明在默认情况下,通过运行以下命令将安装一些MySQL Server 8。

sudo apt install mysql-server

打印Dockerized MariaDB/MySQL Server版本:

当我备份一个WordPress站点时——在这种情况下是容器化的——我在文件名中捕获WordPress版本以及备份时的当前DB版本。这确保了如果我需要恢复,我就不会在确定哪个版本的DB适用于特定版本的WordPress备份时遇到兼容性问题。

因此,我在转储名称中包含了DB服务器版本。我将以下内容加载到一个自填充变量中:

docker exec -it ContainerIdOfDB mysqld --version | awk '{print $3}' | cut -d'-' -f1

这将输出当前的DB版本,而无需登录来检索它。