리눅스 MySQL 버전 확인 - linugseu MySQL beojeon hwag-in

준호씨의 블로그

개발이야기

MySQL 버전 확인 방법

준호씨 2020. 3. 22. 22:13

MySQL 버전 확인 방법들에 대해서 알아봅니다. 개인적으로는 서버 접속해서 sql로 확인해 보는 게 가장 좋네요. 여러 다른 방법들을 정리해 보았으니 상황에 따라 사용하실 수 있습니다.

mysql 커맨드로 확인하기

mysql 이 설치되어 있는 서버에서 직접 확인하는 방법입니다. mysql --version이나 mysql -V로 확인하면 됩니다. 둘 다 같습니다.

$ mysql --version mysql Ver 14.14 Distrib 5.7.29, for Linux (x86_64) using EditLine wrapper$ mysql -V mysql Ver 14.14 Distrib 5.7.29, for Linux (x86_64) using EditLine wrapper

다만 mysql 서버가 별도로 있다면 직접 들어가야 되는 번거로움이 있습니다. DBA가 아니면 서버에 ssh 접근 권한이 없을 수도 있는데 그럴 때는 이 방법으로는 확인할 수 없습니다. 괜히 내 컴퓨터에서 실행하다가 엉뚱한 버전을 확인하게 될 수도 있습니다.

mysql 접속해서 확인하기

mysql 클라이언트로 서버에 접속하면 버전을 바로 확인해 볼 수 있습니다.

$ mysql -uroot Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 39 Server version: 5.7.29-log MySQL Community Server (GPL) Copyright (c) 2000, 2020, 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 -h<hostname> -u<userid> -p <database>

SQL로 확인하기

커맨드 라인 명령이 익숙하지 않아서 별도의 SQL UI 툴을 이용하고 있을 수 도 있습니다. 그런 경우 mysql 서버에 접속한 다음 SQL로 확인하는 게 편합니다.

select version();으로 간단히 확인할 수 있습니다.

mysql> select version(); +-------------------------+ | version() | +-------------------------+ | 5.7.29-0ubuntu0.18.04.1 | +-------------------------+ 1 row in set (0.00 sec)

조금 더 자세한 정보들을 확인하고 싶다면 show variables like '%version%';으로 확인할 수 있습니다.

mysql> SHOW VARIABLES LIKE '%VERSION%'; +-------------------------+-------------------------+ | Variable_name | Value | +-------------------------+-------------------------+ | innodb_version | 5.7.29 | | protocol_version | 10 | | slave_type_conversions | | | tls_version | TLSv1,TLSv1.1,TLSv1.2 | | version | 5.7.29-0ubuntu0.18.04.1 | | version_comment | (Ubuntu) | | version_compile_machine | x86_64 | | version_compile_os | Linux | +-------------------------+-------------------------+ 8 rows in set (0.02 sec)

centos

redhat계열의 linux 환경에서는 rpm 커맨드로 확인할 수도 있습니다. redhat 계열로는 redhat, centos, fedora 등이 있겠네요.

$ rpm -qa | grep mysql mysql-community-libs-5.7.29-1.el7.x86_64 mysql-community-libs-compat-5.7.29-1.el7.x86_64 mysql-community-server-5.7.29-1.el7.x86_64 mysql-community-client-5.7.29-1.el7.x86_64 mysql-community-common-5.7.29-1.el7.x86_64

yum 커맨드로도 확인할 수 있습니다.

$ yum list installed maria* Loaded plugins: fastestmirror, langpacks, versionlock Loading mirror speeds from cached hostfile Installed Packages mariadb.x86_64 1:5.5.64-1.el7 @base mariadb-libs.x86_64 1:5.5.64-1.el7 @base

다만 직접 빌드해서 설치했다거나 압축 풀어서 설치했다면 이 방법으로는 확인이 안 될 수도 있습니다.

ubuntu

debian계열의 linux 환경에서는 dpkg 커맨드로 확인할 수도 있습니다. 대표적으로 ubuntu가 있습니다.

$ dpkg -l | grep mysql-server ii mysql-server 5.7.29-0ubuntu0.18.04.1 all MySQL database server (metapackage depending on the latest version) ii mysql-server-5.7 5.7.29-0ubuntu0.18.04.1 amd64 MySQL database server binaries and system database setup ii mysql-server-core-5.7 5.7.29-0ubuntu0.18.04.1 amd64 MySQL database server binaries

osx

osx에서 homebrew로 설치했다면 brew info mysql로 확인해 볼 수 있습니다.

$ brew info mysql mysql: stable 8.0.19 (bottled)

Toplist

최신 우편물

태그