MySQL查看版本的方法有哪些

数据库   发布日期:2023年07月17日   浏览次数:240

本文小编为大家详细介绍“MySQL查看版本的方法有哪些”,内容详细,步骤清晰,细节处理妥当,希望这篇“MySQL查看版本的方法有哪些”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。

方法一:登录 MySQL

每次通过 mysql 客户端连接服务器之后,都会显示一个欢迎信息,里面包含了服务器的版本:

mysql -uroot
Enter password: ******

Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 21
Server version: 8.0.32 MySQL Community Server - GPL

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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.

方法二:@@version 变量

MySQL 全局变量 @@version 存储了服务器的版本号,我们可以利用一个简单的 SELECT 语句查询其中的信息。例如:

SELECT @@version;

查询结果示例如下:

+-----------+
| @@version |
+-----------+
| 8.0.32 |
+-----------+

方法三:VERSION() 函数

系统函数 VERSION() 也可以返回 MySQL 服务器的版本信息,例如:

SELECT VERSION();

+-----------+
| VERSION() |
+-----------+
| 8.0.32    |
+-----------+

方法四:SHOW VARIABLES 语句

SHOW VARIABLES 语句可以返回 MySQL 系统变量。通过添加 WHERE 条件,我们可以获取服务器的版本信息:

SHOW VARIABLES
WHERE variable_name LIKE 'version%';

+--------------------------+-----------------------------+
| Variable_name            | Value                       |
+--------------------------+-----------------------------+
| version                  | 8.0.32                      |
| version_comment          | MySQL Community Server - GPL|
| version_compile_machine  | x86_64                      |
| version_compile_os       | Win64                       |
| version_compile_zlib     | 1.2.11                      |
+--------------------------+-----------------+

方法五:STATUS 命令

连接到 MySQL 服务器之后,输入 STATUS 命令可以返回版本和其他信息:

STATUS;

返回结果示例如下:

--------------
C:Program FilesMySQLMySQL Server 8.0inmysql.exe Ver 8.0.32 for Win64 on x86_64 (MySQL Community Server - GPL)

Connection id: 21
Current database:
Current user: root@localhost
SSL: Cipher in use is TLS_AES_256_GCM_SHA384
Using delimiter: ;
Server version: 8.0.32 MySQL Community Server - GPL
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: gbk
Conn. characterset: gbk
TCP port: 3306
Binary data as: Hexadecimal
Uptime: 12 days 10 hours 10 min 48 sec

Threads: 2 Questions: 443 Slow queries: 0 Opens: 350 Flush tables: 3 Open tables: 251 Queries per second avg: 0.000
--------------

以上就是MySQL查看版本的方法有哪些的详细内容,更多关于MySQL查看版本的方法有哪些的资料请关注九品源码其它相关文章!