(1).select
显示当前日期和时间
mysql> select now(); +---------------------+ | now() | +---------------------+ | 2019-06-05 13:46:20 | +---------------------+ 1 row in set (0.00 sec)
显示当前日期
mysql> select curdate(); +------------+ | curdate() | +------------+ | 2019-06-05 | +------------+ 1 row in set (0.04 sec)
显示当前时间
mysql> select curtime(); +-----------+ | curtime() | +-----------+ | 13:48:15 | +-----------+ 1 row in set (0.00 sec)
显示当前所在数据库
mysql> use test_db; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select database(); +------------+ | database() | +------------+ | test_db | +------------+ 1 row in set (0.00 sec)
显示Mysql版本
mysql> select version(); +-----------+ | version() | +-----------+ | 5.7.16 | +-----------+ 1 row in set (0.00 sec)
显示当前用户
mysql> select user(); +----------------+ | user() | +----------------+ | root@localhost | +----------------+ 1 row in set (0.00 sec)
(2).show
show variables;显示变量
show global variables;显示全局变量
show global variables like '%version%';显示版本信息
mysql> show global variables like '%version%'; +-------------------------+------------------------------+ | Variable_name | Value | +-------------------------+------------------------------+ | innodb_version | 5.7.16 | | protocol_version | 10 | | slave_type_conversions | | | tls_version | TLSv1,TLSv1.1 | | version | 5.7.16 | | version_comment | MySQL Community Server (GPL) | | version_compile_machine | x86_64 | | version_compile_os | Linux | +-------------------------+------------------------------+ 8 rows in set (0.00 sec)
show variables like '%storage_engine%';显示默认的存储引擎
mysql> show variables like '%storage_engine%'; +----------------------------------+--------+ | Variable_name | Value | +----------------------------------+--------+ | default_storage_engine | InnoDB | | default_tmp_storage_engine | InnoDB | | disabled_storage_engines | | | internal_tmp_disk_storage_engine | InnoDB | +----------------------------------+--------+ 4 rows in set (0.00 sec)