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?
18 answers
Tenta esta função -
SELECT VERSION();
-> '5.7.22-standard'
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
Tenta
mysql --version
Por exemplo. Ou dpkg -l 'mysql-server*'
.
Utilizar {[[0]} funciona bem para mim no Ubuntu.
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
Para UBUNTU pode tentar o seguinte comando para verificar a versão de mysql:
mysql --version
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.
shell> mysql --version
shell> mysql -V
mysqladmin version
ou mysqladmin -V
A partir da consola você pode tentar:
mysqladmin version -u USER -p PASSWD
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)
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)
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 |
+-----------+
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>
Tentei isso no Ubuntu e em outro Linux varian, {[[0]} e funciona muito bem.
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)
No windows, obter cmd e digitar MySQL-V ou MySQL -- version
Se usar o Linux get terminal e escrever MySQL-v
Para Mac,
Autenticar-se no servidor de mysql.
-
Execute o seguinte comando:
SHOW VARIABLES LIKE "%version%";