使用select和show命令查看MySQL数据库系统信息

挖数网精选
挖数网精选
挖数网精选
355
文章
0
评论
2020-04-2002:05:00 评论 348 1821字
摘要

当我们使用一个数据库的时候,了解数据库的系统信息将有助于我们对数据库的理解与操作,如何让用代码获得数据库的系统信息?接下来我们将介绍怎么用select和show命令查看mysql数据库系统信息。

一.select

  显示当前日期和时间

  1. mysql> select now();
  2. +---------------------+
  3. | now() |
  4. +---------------------+
  5. |2019-06-05 13:46:20|
  6. +---------------------+
  7. 1 row in set(0.00 sec)

显示当前日期

  1. mysql> select curdate();
  2. +------------+
  3. | curdate() |
  4. +------------+
  5. |2019-06-05|
  6. +------------+
  7. 1 row in set(0.04 sec)

显示当前时间

  1. mysql> select curtime();
  2. +-----------+
  3. | curtime() |
  4. +-----------+
  5. |13:48:15|
  6. +-----------+
  7. 1 row in set(0.00 sec)

显示当前所在数据库

  1. mysql> use test_db;
  2. Reading table information for completion of table and column names
  3. You can turn off this feature to get a quicker startup with -A
  4. Database changed
  5. mysql>select data base();
  6. +------------+
  7. | database() |
  8. +------------+
  9. | test_db |
  10. +------------+
  11. 1 row in set(0.00 sec)

显示Mysql版本

  1. mysql> select version();
  2. +-----------+
  3. | version() |
  4. +-----------+
  5. |5.7.16|
  6. +-----------+
  7. 1 row in set(0.00 sec)

显示当前用户

  1. mysql> select user();
  2. +----------------+
  3. | user() |
  4. +----------------+
  5. | root@localhost |
  6. +----------------+
  7. 1 row in set(0.00 sec)

二.show

show variables;显示变量

  show global variables;显示全局变量

  show global variables like "%version%";显示版本信息

  1. mysql> show global variables like "%version%";
  2. +-------------------------+------------------------------+
  3. | Variable_name | Value |
  4. +-------------------------+------------------------------+
  5. | innodb_version |5.7.16 |
  6. | protocol_version |10 |
  7. | slave_type_conversions | |
  8. | tls_version | TLSv1, TLSv1.1 |
  9. | version |5.7.16|
  10. | version_comment |MySQL CommunityServer(GPL) |
  11. | version_compile_machine | x86_64 |
  12. | version_compile_os | Linux |
  13. +-------------------------+------------------------------+
  14. 8 rows in set(0.00 sec)

show variables like "%storage_engine%";显示默认的存储引擎

  1. mysql> show variables like"%storage_engine%";
  2. +----------------------------------+--------+
  3. | Variable_name | Value |
  4. +----------------------------------+--------+
  5. | default_storage_engine | InnoDB |
  6. | default_tmp_storage_engine | InnoDB |
  7. | disabled_storage_engines | |
  8. | internal_tmp_disk_storage_engine | InnoDB |
  9. +----------------------------------+--------+
  10. 4 rows in set(0.00 sec)

End.

作者:苦逼运维

来源:博客园

  • 我的微信公众号
  • 微信扫一扫
  • weinxin
  • 我的微信公众号
  • 微信扫一扫
  • weinxin
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: