Como obter a versão actual de uma base de dados MySQL?

Qual o comando que devolve a versão actual de uma base de dados MySQL?

 287
Author: Florent Morselli, 2012-01-24

18 answers

Tenta esta função -

SELECT VERSION();
-> '5.7.22-standard'

Versão()

Ou para mais detalhes use:

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)

Manual de referência MySQL 5.0 (pdf) - determinação da sua versão actual do MySQL-página 42

 492
Author: Devart, 2017-12-18 20:06:15

Tenta

mysql --version
Por exemplo. Ou dpkg -l 'mysql-server*'.
 157
Author: Michael Krelin - hacker, 2012-01-24 13:35:14

Utilizar {[[0]} funciona bem para mim no Ubuntu.

 25
Author: Umesh Kaushik, 2017-12-17 19:31:52
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)

Manual de referência MySQL 5.0 (pdf) - determinação da sua versão actual do MySQL-página 42

 15
Author: John Woo, 2017-12-18 17:37:41

Para UBUNTU pode tentar o seguinte comando para verificar a versão de mysql:

mysql --version
 14
Author: Muhammad waqas muneer, 2013-12-05 08:49:23
Encontrei uma maneira fácil de conseguir isso.

Exemplo: comando Unix(desta forma você não precisa de 2 comandos.),

$ mysql -u root -p -e 'SHOW VARIABLES LIKE "%version%";'

Resultados da amostra:

+-------------------------+-------------------------+
| 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        |
+-------------------------+-------------------------+

No caso acima, a versão do mysql é 5.5.49.

Por favor, encontre esta referência útil.

 14
Author: tk_, 2016-06-30 07:18:51
shell> mysql --version

shell> mysql -V
 9
Author: Nanhe Kumar, 2014-01-13 07:20:42

mysqladmin version ou mysqladmin -V

 9
Author: Singh Anuj, 2014-11-01 02:49:19

A partir da consola você pode tentar:

mysqladmin version -u USER -p PASSWD
 7
Author: spike, 2012-08-02 18:04:22

Basta entrar no Mysql com

mysql -u root -p

Então escreva neste comando

select @@version;

Isto dará o resultado como,

+-------------------------+
| @@version               |
+-------------------------+
| 5.7.16-0ubuntu0.16.04.1 |
+-------------------------+
1 row in set (0.00 sec)
 5
Author: Nirojan Selvanathan, 2016-12-28 06:13:35

Logon para o seu mysql, copiar e colar isto:

SHOW VARIABLES LIKE "%version%";

Saída da amostra:

    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)
 4
Author: Ngo Anh Tuan-HEDSPI, 2014-07-19 09:36:43

Com CLI numa linha:

mysql --user=root --password=pass --host=localhost db_name --execute='select version()';

Ou

mysql -uroot -ppass -hlocalhost db_name -e 'select version()';

Devolve algo assim:

+-----------+
| version() |
+-----------+
| 5.6.34    |
+-----------+
 3
Author: Nolwennig, 2017-04-11 14:39:33

Você também pode olhar para o topo da shell MySQL quando você faz login pela primeira vez. Na verdade, mostra a versão ali.

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>
 2
Author: David Duggins, 2016-12-23 20:24:58

Tentei isso no Ubuntu e em outro Linux varian, {[[0]} e funciona muito bem.

 1
Author: Dariel Pratama, 2016-11-21 02:55:02
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)
 1
Author: Abhay Singh, 2017-04-19 10:16:28

No windows, obter cmd e digitar MySQL-V ou MySQL -- version

Se usar o Linux get terminal e escrever MySQL-v

 1
Author: teran teshara, 2018-08-18 15:23:42

Mysql Client version:

Mysql -version 

Versão do servidor Mysql: existem muitas maneiras de encontrar

  1. SELECT version();

enter image description here

  1. SHOW VARIABLES LIKE "%version%";

enter image description here

 1
Author: FullStack, 2018-08-31 09:34:42

Para Mac,

  1. Autenticar-se no servidor de mysql.

  2. Execute o seguinte comando:

     SHOW VARIABLES LIKE "%version%";
    
 0
Author: KayV, 2018-08-09 07:39:27