MySQL查看版本的五种方法总结

在日常项目开发过程中,我们经常要连接自己的数据库,此时不知道数据库的版本是万万不可的,下面这篇文章主要给大家介绍了关于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 Files\MySQL\MySQL Server 8.0\bin\mysql.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查看版本内容请搜索0133技术站以前的文章或继续浏览下面的相关文章希望大家以后多多支持0133技术站!

以上就是MySQL查看版本的五种方法总结的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » 数据库