MySQL提供了许多提供当前连接信息的功能。例如,要了解当前用户,请使用此user()方法。
语法mysql> SELECT CURRENT_USER();
这是显示当前用户名称的输出。+----------------+
| CURRENT_USER() |
+----------------+
| root@% |
+----------------+
1 row in set (0.00 sec)
在上面,%告诉我们有关本地主机的信息。
要检查当前的连接ID,请使用以下方法-mysql> SELECT CONNECTION_ID();
以下是显示当前连接ID的输出。+-----------------+
| CONNECTION_ID() |
+-----------------+
| 8 |
+-----------------+
1 row in set (0.02 sec)
以下是使用单个命令检查所有当前信息的语法。mysql> status;
以下是输出---------------
C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe Ver 8.0.12 for Win64 on x86_64 (MySQL Community Server - GPL)
Connection id: 8
Current database: business
Current user: root@localhost
SSL: Cipher in use is DHE-RSA-AES128-GCM-SHA256
Using delimiter: ;
Server version: 8.0.12 MySQL Community Server - GPL
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: cp850
Conn. characterset: cp850
TCP port: 3306
Uptime: 1 hour 11 min 24 sec
Threads: 2 Questions: 26 Slow queries: 0 Opens: 129 Flush tables: 2 Open tables: 105 Queries per second avg: 0.006
--------------