在日常项目开发过程中,我们经常要连接自己的数据库,此时不知道数据库的版本是万万不可的。今天小树懒来给大家总结一下查看mysql版本的方法。
MySQL查看版本的方法主要有以下四种
方法1:
没有连接到MySQL终端下直接使用mysql命令。打开cmd,切换至 MySQL的bin目录,运行以下命令:
[root@localhost lib]# mysql-VmysqlVer15.1Distrib5.5.47-MariaDB, forLinux(x86_64) usingreadline5.1
方法2:
同样在终端使用命令
[root@localhostlib]#mysql--help|grepDistribmysqlVer15.1Distrib5.5.47-MariaDB,forLinux(x86_64)usingreadline5.1
方法3:
如果已经连接到了 MySQL ,则可以登陆mysql之后使用内置命令
mysql> selectversion(); +----------------+| version() | +----------------+| 5.5.47-MariaDB | +----------------+1row inset (0.00sec)
方法4:
同样登录MySQL,使用内置命令
mysql>status;--------------mysqlVer15.1Distrib5.5.47-MariaDB,forLinux(x86_64)usingreadline5.1Connection id:4Current database:Current user:root@localhostSSL:NotinuseCurrent pager:stdoutUsing outfile:''Using delimiter:;Server:MariaDBServer version:5.5.47-MariaDBMariaDBServerProtocol version:10Connection:LocalhostviaUNIXsocketServer characterset:latin1Db characterset:latin1Client characterset:utf8Conn. characterset:utf8UNIX socket:/var/lib/mysql/mysql.sockUptime:2min56secThreads: 1 Questions: 12 Slow queries: 0 Opens: 0 Flush tables: 2 Opentables: 4 Queries per second avg:0.068
或者
mysql>\s--------------mysqlVer14.14Distrib5.6.32,forWin32(AMD64)Connection id:9Current database:Current user:root@localhostSSL:NotinuseUsing delimiter:;Server version:5.6.32-logMySQLCommunityServer(GPL)Protocol version:10Connection:localhostviaTCP/IPServer characterset:latin1Db characterset:latin1Client characterset:gbkConn. characterset:gbkTCP port:3307Uptime:4hours9min29secThreads: 4 Questions: 144 Slow queries: 0 Opens: 73 Flush tables: 1 Open tables: 66 Queries per second avg:0.009
以上就是常见的四种mysql查看版本的方法。
其实,在命令行连接上MySQL服务器时,其实就已经显示了MySQL的版本,如:
e:\mysql\bin>mysql -uroot -p -P3307Enterpassword:Welcometo the MySQL monitor. Commands end with ; or \g.YourMySQL connection id is 10Serverversion: 5.6.32-log MySQL Community Server (GPL)Copyright(c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracleis a registered trademark of Oracle Corporation and/or itsaffiliates.Other names may be trademarks of their respectiveowners.Type'help;' or '\h' for help. Type '\c' to clear the current input statement.