MySQLのバージョンを確認する方法

mysql_logo_large

この記事には広告を含む場合があります。

記事内で紹介する商品を購入することで、当サイトに売り上げの一部が還元されることがあります。

MySQLのバージョンを調べる

この記事では、MySQL のバージョンを確認する方法をお伝えします。

MySQL はバージョンごとに対応している機能が異なるため、ウェブサイトを作成する上で事前にチェックしたい項目です。ただ MySQL のバージョンを確認する方法は忘れがちなので、本サイトを参考にして頂ければ幸いです。

 

MySQLバージョンの確認方法

MySQL のバージョンを確認する方法を4つご紹介します。

環境によりコマンドの実行に必要なパッケージがインストールされていない可能性があります。ご自身の環境で一番簡単な確認方法を選んでください。

コマンドラインから MySQL のバージョンを確認する

Linux のコマンドライン上から MySQL のバージョンを確認するときは、mysql コマンドを使用します。

コマンドサンプル

mysql –version

コマンドサンプルの実行例

root@localhost:# mysql --version
mysql  Ver 14.14 Distrib 5.7.25, for debian-linux-gnu (x86_64) using  EditLine wrapper

 

MySQL にログインしてバージョンを確認する

MySQL にログインすると、MySQL のバージョンを確認することができます。

root@localhost:# mysql -hlocalhost -uroot -p
Enter password: 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1149
Server version: 5.7.25 debian

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 のバージョンを確認する SQL を実行する

MySQL にてバージョンを確認する SQL が用意されています。

SQLサンプル

select version();

SQLサンプルの実行例

mysql>
+-----------+
| version() |
+-----------+
| 5.7.25    |
+-----------+
1 row in set (0.01 sec)

 

MySQL のステータスを確認する SQL を実行する

MySQL のステータスを確認する SQL を実行した画面でも、MySQL のバージョンを確認することができます。

SQLサンプル

status

SQLサンプルの実行例

mysql> status
--------------
mysql  Ver 14.14 Distrib 5.7.25, for debian-linux-gnu (x86_64) using  EditLine wrapper

Connection id:          1149
Current database:
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.7.25 debian
Protocol version:       10
Connection:             localhost via TCP/IP
Server characterset:    utf8
Db     characterset:    utf8
Client characterset:    utf8
Conn.  characterset:    utf8
TCP port:               3306
Uptime:                 12 days 4 hours 14 min 5 sec

Threads: 1  Questions: 12 Slow queries: 0  Opens: 207  Flush tables: 1  Open tables: 106  Queries per second avg: 0.028
--------------

 

 

ウェブプログラミングについては下記の本も参考になるので、スキルアップにお役立てください。

created by Rinker
徳丸 浩(著)
ページ数: 688ページ
出版社:SBクリエイティブ
発売日:2018/06/21

出典:amazon