0x00 查询MySql安装路径

select @@basedir;

  1. mysql> select @@basedir;
  2. +--------------------------------+
  3. | @@basedir |
  4. +--------------------------------+
  5. | D:/phpStudy/PHPTutorial/MySQL/ |
  6. +--------------------------------+
  7. 1 row in set (0.00 sec)

0x01 查询当前连接数据库

select database();

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

0x02 查询用户

select user();

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

select current_user;

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

select current_user();

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

select system_user();

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

select SESSION_USER();

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

0x03 查询当前连接的数据库版本

select version();

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

select @@version;

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

0x04 文件读取最大值

select @@max_allowed_packet;

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

0x05 查看MySQL数据存储路径

select @@datadir

  1. mysql> select @@datadir;
  2. +----------------------------------------------+
  3. | @@datadir |
  4. +----------------------------------------------+
  5. | E:\phpstudy_pro\Extensions\MySQL5.7.26\data\ |
  6. +----------------------------------------------+
  7. 1 row in set (0.00 sec)


0x06 连接数据库的用户名

select session_user()

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

0x07 数据库服务器的信息

select @@version_comment

  1. mysql> select @@version_comment;
  2. +------------------------------+
  3. | @@version_comment |
  4. +------------------------------+
  5. | MySQL Community Server (GPL) |
  6. +------------------------------+
  7. 1 row in set (0.00 sec)

0x08 操作系统版本

select @@version_compile_os

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

0x09 查看机器的型号

select @@version_compile_machine

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