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


当前回答

这里还有两个方法:

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

其他回答

Xampp与Windows用户在下面的命令中工作在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)

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

有时候,知道默认安装的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

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