什麼命令返回當前版本的MySQL數據庫?如何檢索當前版本的MySQL數據庫?
回答
試試這個功能 -
SELECT VERSION();
-> '5.7.22-standard'
或瞭解更多詳細信息,使用方法:
SHOW VARIABLES LIKE "%version%";
+-------------------------+------------------------------------------+
| Variable_name | Value |
+-------------------------+------------------------------------------+
| protocol_version | 10 |
| version | 5.0.27-standard |
| version_comment | MySQL Community Edition - Standard (GPL) |
| version_compile_machine | i686 |
| version_compile_os | pc-linux-gnu |
+-------------------------+------------------------------------------+
5 rows in set (0.04 sec)
MySQL 5.0 Reference Manual (pdf) - Determining Your Current MySQL Version - page 42
嘗試
mysql --version
例如。或者dpkg -l 'mysql-server*'
。
這是最好的快速選項,如果你懶惰 - 你甚至不需要登錄':-D'在Centos/RHEL命令行以及Ubuntu上都可以正常工作。 – user568458
@ user568458,不過,它會給你客戶端的版本或本地服務器的版本,只要作爲一個包安裝的那個版本正在運行;) –
命令mysql -version不是操作系統特定的。這將適用於任何Linux發行版,Windows和OS X. –
SHOW VARIABLES LIKE "%version%";
+-------------------------+------------------------------------------+
| Variable_name | Value |
+-------------------------+------------------------------------------+
| protocol_version | 10 |
| version | 5.0.27-standard |
| version_comment | MySQL Community Edition - Standard (GPL) |
| version_compile_machine | i686 |
| version_compile_os | pc-linux-gnu |
+-------------------------+------------------------------------------+
5 rows in set (0.04 sec)
MySQL 5.0 Reference Manual (pdf) - Determining Your Current MySQL Version - page 42
從控制檯,您可以嘗試:
mysqladmin version -u USER -p PASSWD
shell> mysql --version
shell> mysql -V
登錄到你的MySQL,複製並粘貼此:
SHOW VARIABLES LIKE "%version%";
輸出示例:
mysql> SHOW VARIABLES LIKE "%version%";
+-------------------------+---------------------+
| Variable_name | Value |
+-------------------------+---------------------+
| protocol_version | 10 |
| version | 5.1.73 |
| version_comment | Source distribution |
| version_compile_machine | i386 |
| version_compile_os | redhat-linux-gnu |
+-------------------------+---------------------+
5 rows in set (0.00 sec)
mysqladmin version
OR mysqladmin -V
使用mysql -V
在Ubuntu上爲我工作得很好。
我找到了一個簡單的方法來得到它。
實施例:Unix命令(這樣就不需要2個命令),
$ mysql -u root -p -e 'SHOW VARIABLES LIKE "%version%";'
樣本輸出:
+-------------------------+-------------------------+
| Variable_name | Value |
+-------------------------+-------------------------+
| innodb_version | 5.5.49 |
| protocol_version | 10 |
| slave_type_conversions | |
| version | 5.5.49-0ubuntu0.14.04.1 |
| version_comment | (Ubuntu) |
| version_compile_machine | x86_64 |
| version_compile_os | debian-linux-gnu |
+-------------------------+-------------------------+
在上述情況下,MySQL的版本49年5月5日。
在Ubuntu和其他linux varian,SELECT @@version
上試過這個,並且工作得很好。
您也可以在第一次登錄時查看MySQL shell的頂部。它實際上顯示了當前的版本。
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 67971
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
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>
只需登錄到MySQL與
mysql -u root -p
然後在一種類型的該命令中
select @@version;
這會給該結果作爲,
+-------------------------+
| @@version |
+-------------------------+
| 5.7.16-0ubuntu0.16.04.1 |
+-------------------------+
1 row in set (0.00 sec)
隨着CLI行:
mysql --user=root --password=pass --host=localhost db_name --execute='select version()';
或
mysql -uroot -ppass -hlocalhost db_name -e 'select version()';
回報是這樣的:
+-----------+
| version() |
+-----------+
| 5.6.34 |
+-----------+
E:\>mysql -u root -p
Enter password: *******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1026
Server version: 5.6.34-log MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
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> select @@version;
+------------+
| @@version |
+------------+
| 5.6.34-log |
+------------+
1 row in set (0.00 sec)
您能否爲您的答案提供一些背景知識。雖然它清楚地表明瞭一種解決方案,但對於您的方法以及爲什麼它有一個好方法會有所幫助。通常只是發佈代碼塊在SO中被壓低。 –
我不認爲需要任何解釋爲什麼'SELECT @@ version;',它顯示版本,將是一個很好的方法來顯示版本。國際海事組織的更大問題是,這個答案是以前答案的重複。 –
- 1. 檢索當前的SQL Server版本
- 2. 如何檢索從基於MYSQL數據庫當前登錄的用戶憑據
- 3. 如何檢索MySql中的當前星期數據?
- 4. 如何閱讀dexie中的當前數據庫版本號?
- 5. 從mysql數據庫檢索timestamp值返回當前日期
- 6. 從mysql數據庫檢索文本
- 7. 檢索MySQL數據庫
- 8. 檢索MySQL數據庫
- 9. 如何使用PHP搜索欄檢索MySQL數據庫數據
- 10. 如何用svn的版本庫替換當前版本?
- 11. 如何從數據庫檢索樣本?
- 12. 如何從Hive中讀取hbase當前版本和以前版本的數據
- 13. Visual Studio數據庫版 - 我有當前版本嗎?
- 14. 從yii2當前用戶登錄數據庫檢索數據
- 15. 如何使用[DATE]函數根據當前月份從mySQL數據庫檢索數據?
- 16. 如何從iPhone上的MAMP MySQL數據庫檢索數據?
- 17. 如何從MySql數據庫檢索微調器數據的值
- 18. 如何檢索數據庫mysql中的數據。 android studio
- 19. 從MySQL數據庫檢索BLOB數據
- 20. PHP與MySQL數據庫檢索數據
- 21. 從mysql數據庫檢索數據
- 22. 從MySQL數據庫中檢索數據
- 23. 如何使用當前日期從數據中檢索數據
- 24. 從MySQL數據庫中檢索當前用戶ID使用的Visual Basic 2008
- 25. 從以前的iOS應用版本檢索數據
- 26. 如何使用jdbc從MySQL數據庫檢索數據?
- 27. 如何使用MySqlDataReader從數據庫mySQL檢索數據?
- 28. 如何從mysql數據庫中檢索數據
- 29. 如何加速從Mysql數據庫中檢索數據
- 30. 如何檢查當前在我的mysql數據庫中運行的查詢?
http://dev.mysql.com/doc/refman/5.0/en/ installation-version.html是404. –
如果我不想運行任何與mysql本身相關的東西,該怎麼辦?這個版本信息存儲在哪裏? – Sajuuk