如何在Ubuntu Linux中查看MySQL版本

检查MySQL Server版本

MySQL和MariaDB具有内置的工具,允许我们检查服务器版本。

mysqld --version

输出示例

MySQL output:
/usr/sbin/mysqld  Ver 8.0.23-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))
MariaDB output:
mysqld  Ver 10.3.25-MariaDB-0ubuntu0.20.04.1 for debian-linux-gnu on x86_64 (Ubuntu 20.04)

如果在下面运行该命令,也应该显示服务器版本

mysqladmin -V

输出示例:

MySQL output:
mysqladmin  Ver 8.0.23-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))
MariaDB output:
mysqladmin  Ver 9.1 Distrib 10.3.25-MariaDB, for debian-linux-gnu on x86_64

MySQL和MariaDB自带客户端工具,也应该找到服务器版本。
从命令行中,通过在下面运行命令来调用客户端工具:

sudo mysql

登录时将显示包括版本号的服务器详细信息。

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.23-0ubuntu0.20.04.1 (Ubuntu)
Copyright (c) 2000, 2021, 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.
mysql>

MariaDB服务器将输出以下消息:

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 49
Server version: 10.3.25-MariaDB-0ubuntu0.20.04.1 Ubuntu 20.04
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>

或者运行STATUS查询来显示包含版本号的服务器详细信息。

mysql> STATUS;

输出示例:

Connection id:        9
 Current database:    
 Current user:        root@localhost
 SSL:            Not in use
 Current pager:        stdout
 Using outfile:        ''
 Using delimiter:    ;
 Server version:        8.0.23-0ubuntu0.20.04.1 (Ubuntu)
 Protocol version:    10
 Connection:        Localhost via UNIX socket
 Server characterset:    utf8mb4
 Db     characterset:    utf8mb4
 Client characterset:    utf8mb4
 Conn.  characterset:    utf8mb4
 UNIX socket:        /var/run/mysqld/mysqld.sock
 Binary data as:        Hexadecimal
 Uptime:            6 min 54 sec
 Threads: 2  Questions: 5  Slow queries: 0  Opens: 117  Flush tables: 3  Open tables: 36  Queries per second avg: 0.012
日期:2020-07-07 20:55:04 来源:oir作者:oir