How To Check The MySQL Version In Linux

Introduction

It is essential to know which version of MySQL you have installed.

Knowing the version number helps to determine if a specific feature is available or compatible with your system. This article provides five options to check your version of MySQL on Linux operating systems.

知道版本号有助于确定特定功能是否可用或与您的系统兼容。本文提供了五个选项来检查Linux操作系统上的MySQL版本

Prerequisites

先决条件

  • Access to the command line/terminal window

    进入命令行/终端窗口

  • Some operations require sudo or root privileges

    某些操作需要sudo或root特权

  • MySQL or MySQL fork installed (forks: MariaDB, Percona Server )

    安装了MySQL或MySQL分支(分支:MariaDB,Percona Server)

Check MySQL Version with V Command

使用V命令检查MySQL版本

The easiest way to find the MySQL version is with the command:

发现MySQL版本的最简单方法是使用以下命令:

mysql -V

The command mysql –V is not OS specific. This command works on Windows, OS X, and Linux distributions including Ubuntu.

命令mysql –V不是特定于操作系统的。该命令可在Windows,OS X和Linux发行版(包括Ubuntu)上使用

The MySQL client version in the example above is 10.4.5-MariaDB.

Note: The command provides the version of the MySQL client utility. The version could be the same as the MySQL server utility if installed on the same system as the server. However, if the client and server utilities are installed on different systems, they might not be the same.

注意:该命令提供了MySQL客户端实用程序的版本。如果与服务器安装在同一系统上,则该版本可能与MySQL服务器实用程序相同。但是,如果客户端和服务器实用程序安装在不同的系统上,则它们可能会不同

How to Find Version Number with mysql Command

如何使用mysql命令发现版本号

The MySQL command-line client is a simple SQL shell with input editing capabilities. You need to have administrative privileges or use the sudo command to gain access.

MySQL命令行客户端是具有输入编辑功能的简单SQL Shell。您需要具有管理特权或使用sudo命令来获得访问权限

To access your MySQL client, use the command:

要访问您的MySQL客户端,请使用以下命令:

mysql

MySQL version data is available automatically once the MySQL client loads.

MySQL客户端加载后,MySQL版本数据将自动可用

The MySQL client shell offers a lot more options to retrieve detailed information about the version installed.

MySQL客户端shell提供了更多选项来检索有关已安装版本的详细信息

SHOW VARIABLES LIKE Statement

Now that you have accessed the MySQL client shell, statements can provide detailed information about your MySQL installation. Keep in mind that all text commands within the MySQL client must end with a semicolon “;”

现在,您已经访问了MySQL客户端外壳,语句可以提供有关MySQL安装的详细信息。请记住,MySQL客户端中的所有文本命令都必须以分号“;”结尾

Enter the following command:

SHOW VARIABLES LIKE ‘%version%’;

The variable that contains MySQL version information is version.

包含MySQL版本信息的变量是version

SELECT VERSION Statement

It’s possible to obtain the version from within the MYSQL client by typing the SELECT VERSION() statement:

通过键入SELECT VERSION()语句,可以从MYSQL客户端中获取版本:

SELECT VERSION();

This command derives the data from the version variable disregarding other variables.

该命令从版本变量派生数据,而不考虑其它变量

STATUS Command

The STATUS command displays the version as well as version comment information:

STATUS命令显示版本以及版本注释信息:

STATUS;

The output includes uptime (how long the MySQL server has been running), threads (the number of active threads), and other useful information

输出包括正常运行时间(MySQL服务器已运行多长时间),线程(活动线程数)和其他有用的信息

This statement provides the most comprehensive overview regarding the status of the MySQL installation and its current version.

该语句提供有关MySQL安装状态及其当前版本的最全面的概述

Conclusion

You now know how to use the command line to check your MySQL version. Additionally, if you need to get a more detailed account of your MySQL version, this article explained how to display additional data from within the MySQL client.

posted @ 2020-07-11 22:45  PrimerPlus  阅读(215)  评论(0编辑  收藏  举报