MySQL or MariaDB is very popular opensource databases servers. While using these database servers we may need to know the version of the client or server. We can use features according to these version numbers. In this tutorial we will look how to list MySQL and MariaDB database server versions.
MySQL或MariaDB是非常流行的开源数据库服务器。 在使用这些数据库服务器时,我们可能需要了解客户端或服务器的版本。 我们可以根据这些版本号使用功能。 在本教程中,我们将研究如何列出MySQL和MariaDB数据库服务器版本。
mysql –version命令 (mysql –version Command)
mysql
is a client command used to connect and manage database server. We can use --version
option in order to print the version of the mysql client. If the database service runs in the same system this will also print the server version too.
mysql
是用于连接和管理数据库服务器的客户端命令。 我们可以使用--version
选项来打印mysql客户端的版本。 如果数据库服务在同一系统上运行,这还将打印服务器版本。
$ mysql --version
包装经理(Package Manager)
We can use package manager of the system. This can be apt
, yum
or dnf
. In this case we will use apt
with the show
option .
我们可以使用系统的程序包管理器。 这可以是apt
, yum
或dnf
。 在这种情况下,我们将使用apt
和show
选项。
$ apt show mysql-server
As we can see from line Version:
the version is 5.7.23
正如我们从Version:
行看到的Version:
版本是5.7.23
MySQL客户端 (MySQL Client)
In the first connection of the MySQL server some basic information about the server is listed. MySQL server version is one of them. The line starting with Server version:
will show the current version of the MySQL server.
在MySQL服务器的第一个连接中,列出了有关服务器的一些基本信息。 MySQL服务器版本就是其中之一。 以Server version:
开头的行将显示MySQL服务器的当前版本。
$ sudo mysql -u root -p
服务器变量(Server Variables)
MySQL server variables are stored in the VARIABLES
variable. We can use VARIABLES
and fileter for version
information like and SQL statement.
MySQL服务器变量存储在VARIABLES
变量中。 我们可以使用VARIABLES
和fileter来获取version
信息,例如SQL语句。
> SHOW VARIABLES LIKE "%version%";
As we can see also following information is provided too.
如我们所见,还提供了以下信息。
- innodb_version innodb_version
- protocol_version protocol_version
- tls_version tls_version
- version 版
- version_comment版本评论
- version_compile_machineversion_compile_machine
- version_compile_os version_compile_os
状态MySQL命令 (STATUS MySQL Command)
MySQL also provides the STATUS
command which is used to current status of the MySQL server. We can this command to print MySQL server version and other server related information like Connection, Current User, Connection Id etc.
MySQL还提供STATUS
命令,该命令用于显示MySQL服务器的当前状态。 我们可以使用此命令来打印MySQL服务器版本和其他与服务器相关的信息,例如连接,当前用户,连接ID等。
> STATUS;
As we can see that following information is provided too
如我们所见,还提供了以下信息
- Connection id连接ID
- Current database 当前数据库
- Current user当前用户
- SSLSSL协议
- Server version服务器版本
- Protocol version协议版本
- Connection连接
- Server characterset服务器角色集
- Db charactersetdb characterset
- Client characterset 客户特征集
- Conn. characterset连接字符集
- UNIX socketUNIX套接字
- Uptime正常运行时间
- Threads线程数
翻译自: https://www.poftut.com/how-to-check-and-determine-mysql-database-server-version/