Show Users in MySQL

When managing a database is often need to get a list of users which are used to connect to the MySQL server. MySQL provides statements which allows to show databases and tables, but there is no statement to show users.

Show users list

Users are stored in the mysql.user system table. We can get a list of users by running a SELECT statement.

SELECT * FROM mysql.user;

Show current user

We can get the username and hostname for the MySQL user that the server used to authenticate the current client by using CURRENT_USER() function.

| root@localhost |

Show current logged users list

We can use information_schema.processlist table to get a list of users that are currently logged in the MySQL server.

SELECT * FROM information_schema.processlist;

Leave a Comment

Your email address will not be published.