哪个命令返回MySQL数据库的当前版本?
当前回答
MySQL服务器版本
shell> mysqld --version
MySQL客户端版本
shell> mysql --version
shell> mysql -V
其他回答
我找到了一个简单的方法。
例如: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。
请找到这份有用的参考资料。
try
mysql --version
例如。或dpkg -l '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版本,而无需登录来检索它。
试试这个功能-
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页
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)