Home > Database > Mysql Tutorial > How to display MySQL current connection information?

How to display MySQL current connection information?

PHPz
Release: 2023-08-31 15:13:06
forward
1460 people have browsed it

How to display MySQL current connection information?

MySQL provides many functions to obtain information about the current connection. For example, to know the current user, you can use the user() function.

grammar

mysql> SELECT CURRENT_USER();
Copy after login

This is the output showing the current user name.

+----------------+
| CURRENT_USER() |
+----------------+
| root@%         |
+----------------+
1 row in set (0.00 sec)
Copy after login

In the above, % tells us information about localhost.

To check the current connection ID, use the following method -

mysql> SELECT CONNECTION_ID();
Copy after login

The following is the output showing the current connection ID.

+-----------------+
| CONNECTION_ID() |
+-----------------+
|               8 |
+-----------------+
1 row in set (0.02 sec)
Copy after login

The following is the syntax for checking all current information using a single command.

mysql> status;
Copy after login

The following is the output -

--------------
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
--------------
Copy after login

The above is the detailed content of How to display MySQL current connection information?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template