Question:Is there a query to run that will return all Users that are currently logged into MySQL?
Answer: In MySQL, there is a system table called information_schema.processlist which shows the threads that are currently running. You can run a query against this system table that returns all of the Users that are currently have a connection running in the MySQL database.
To retrieve all Users logged into MySQL, you can execute the following SQL statement:
This SELECT statement will return the host, the user, and the number of threads for that host/user combination.
You must have PROCESS privileges to see threads owned by other users. Otherwise, you will only see your own threads.
The information_schema.processlist system table was introduced in MySQL 5.1.7.
The information_schema.processlist table contains the following columns:
User name (ie: root, AODBA, etc)
Host for the user
Database that thread is running in
Command that is being run (ie: Query, Sleep, etc).
Number of seconds that thread has been running (ie: 3, 12, 353)
State of thread (ie: executing)
Displays information about the thread. (ie: if COMMAND='Query' and STATE='executing', the SQL that the user is running will be displayed)