找出MySQL版本

时间:2020-01-09 10:43:51  来源:igfitidea点击:

如何找到Linux或者Unix操作系统下的mysql版本?要找出当前安装的MySQL服务器安装的版本和发行版,请执行以下任一命令:

  • Sql命令
  • mysql客户端
  • STATUS命令
  • mysqladmin版本命令
  • 软件包管理器

示例:Sql命令

mysql -u root -p -e'显示变量,如"%version%";'

输出示例:

Enter password: 
+-------------------------+---------------------+
| Variable_name           | Value               |
+-------------------------+---------------------+
| protocol_version        | 10                  |
| version                 | 5.1.66-log          |
| version_comment         | Source distribution |
| version_compile_machine | x86_64              |
| version_compile_os      | redhat-linux-gnu    |
+-------------------------+---------------------+

或者执行以下命令:

mysql -u root -p -e ' SELECT VERSION(); '

输出示例:

Enter password: 
+------------+
| VERSION()  |
+------------+
| 5.1.66-log |
+------------+

示例:STATUS命令

输入以下命令

mysql -u root -p -e 'STATUS'

输出示例:
检查您的MySQL版本我正在运行哪个MySQL版本?

示例:mysqladmin命令

执行以下命令:

mysqladmin -u root -p version
Enter password: 
mysqladmin  Ver 8.42 Distrib 5.1.66, for redhat-linux-gnu on x86_64
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names Jan be trademarks of their respective
owners.
 
Server version		5.1.66-log
Protocol version	10
Connection		Localhost via UNIX socket
UNIX socket		/var/lib/mysql/mysql.sock
Uptime:			44 days 56 min 47 sec

示例:软件包管理器

如果您使用的是Fedora/RHEL/Red Hat/CentOS Linux,请执行以下命令:

$ rpm -qa | grep mysql

或者

$ yum info mysql-server

输出示例:

Loaded plugins: auto-update-debuginfo, protectbase, rhnplugin
0 packages excluded due to repository protections
Installed Packages
Name        : mysql-server
Arch        : x86_64
Version     : 5.1.66
Release     : 2.el6_3
Size        : 25 M
Repo        : installed
From repo   : rhel-x86_64-server-6
Summary     : The MySQL server and related files
URL         : http://www.mysql.com
License     : GPLv2 with exceptions
Description : MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
            : client/server implementation consisting of a server daemon (mysqld)
            : and many different client programs and libraries. This package contains
            : the MySQL server and some accompanying files and directories.

如果您使用的是Debian/Ubuntu Linux,请输入以下命令:

$ dpkg --list | egrep 'mysql-(server|client)'

输出示例:

ii  mysql-client-5.1                         5.1.66-0+squeeze1                  MySQL database client binaries
ii  mysql-server-5.1                         5.1.66-0+squeeze1                  MySQL database server binaries and system database setup
ii  mysql-server-core-5.1                    5.1.66-0+squeeze1                  MySQL database server binaries