Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does mysql query currently logged-in users

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

In this article, the editor introduces in detail "mysql how to query currently logged-in users", detailed content, clear steps, and proper handling of details. I hope this "mysql how to query currently logged-in users" article can help you solve your doubts, following the editor's ideas slowly in-depth, together to learn new knowledge.

Method: 1, with USER () function, you can return the current user name and hostname of the connection, syntax "select user ()"; 2, with "currrent_user ()" function, you can display the current login user corresponding to one in the user table, syntax "select current_user ()".

The operating environment of this tutorial: centos 7 system, mysql8.0.22 version, Dell G3 computer.

How does mysql query currently logged-in users?

The user () function returns the current user name and hostname of the MySQL connection. Is used to display the user name of the current login and its corresponding host

Currrent_user () is used to show which one of the current login users is in the user table.

User (), to be clear, is a function, not part of the SQL statement (meaning it cannot be used in other databases).

We can help user to get the help of this function.

Teach you how to view currently logged-in users on mysql

You can see that the use method is select user ()

(insensitive to case)

Select user ()

Teach you how to view currently logged-in users on mysql

Need to explain: root@localhost

Root refers to the user we are currently logged in to, and localhost refers to the local host (which database server to log in to). If you have a network foundation, you must know that it points to the loopback address 127.0.0.1.

Another way is to get the current user name through current_user.

Select current_user ()

PS: parentheses may not be added

Examples are as follows:

Mysql > select user (); +-- + | user () | +-+ | test@192.168.203.132 | +-+ 1 row in set (0.00 sec) mysql > select current_user () +-+ | current_user () | +-+ | test@192.168.%.% | +-+ 1 row in set (0.00 sec). This article "how to query currently logged-in users by mysql" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it. If you want to know more about the articles, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report