
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
List logged-in MySQL users?
To list logged-in MySQL users, you can use any of the following two methods −
First Method
Use INFORMATION_SCHEMA.PROCESSLIST
select *from INFORMATION_SCHEMA.PROCESSLIST;
Second Method
You can use SHOW PROCESSLIST command as well. Following is the syntax −
SHOW PROCESSLIST;
Let us implement the above syntaxes in order to list logged in MySQL users −
mysql> select *from information_schema.processlist;
This will produce the following output -
+----+-----------------+-----------------+------+---------+--------+-----------------------------+---------------------------------------------+ | ID | USER | HOST | DB | COMMAND | TIME | STATE | INFO | +----+-----------------+-----------------+------+---------+--------+-----------------------------+---------------------------------------------+ | 8 | root | localhost:50252 | web | Query | 0 | executing | select *from information_schema.processlist | | 4 | event_scheduler | localhost | NULL | Daemon | 301832 | Waiting for next activation | NULL | +----+-----------------+-----------------+------+---------+--------+-----------------------------+---------------------------------------------+ 2 rows in set (0.00 sec)
Now, let us see the second query −
mysql> show processlist;
This will produce the following output -
+----+-----------------+-----------------+------+---------+--------+-----------------------------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+-----------------+-----------------+------+---------+--------+-----------------------------+------------------+ | 4 | event_scheduler | localhost | NULL | Daemon | 301842 | Waiting for next activation | NULL | | 8 | root | localhost:50252 | web | Query | 1 | starting | show processlist | +----+-----------------+-----------------+------+---------+--------+-----------------------------+------------------+ 2 rows in set (0.19 sec)
- Related Articles
- MySQL Select to get users who have logged in today?
- How to list all users who are currently logged into the Linux system?\n
- Find the count of users who logged in between specific dates with MongoDB
- MySQL query to group data in the form of user login time per hour and get the records of the users logged in the recent hour?
- How to list all users in the Mongo shell?
- How to list all users in a Linux group?
- How to update User Logged in Time for a specific user in MySQL?
- Get number of users of different type in MySQL?
- Find all users with a unique last name in MySQL?
- Selecting all the users with maximum age values using a MySQL subquery?
- How to check which Azure account is logged in using PowerShell?
- Python for Spreadsheet Users
- Python for MATLAB Users
- Return list of databases in MySQL?
- What are Data Warehouse Users?

Advertisements