This short article will show you how to list all of the users on your MySQL server.
MySQL Users and Permissions
MySQL databases usually have access granted to only certain users, each with their own permissions limiting what they can and can’t do on that specific database.
As there are often multiple databases on a server, there will be several user accounts – some for different databases, some from different hosts – so it’s useful to be able to list them all out quickly.
Command to List Users
Once you’re connected to your MySQL database server, issue the following command to list the users on the system:
SELECT * FROM mysql.user;
The information for the users on a MySQL server is all stored in the MySQL database in the users table.
Quite a bit of information will be returned – you can return only the information you need by altering the SELECT statement to include only the required columns:
SELECT user, host FROM mysql.user;
While there is a password column, it should be empty, or the contents should be hashed to be of no use. MySQL does not store passwords in plain text, so the contents of that column are of no use.
Get User Privileges
Check out the official documentation here for more detail on how MySQL stores information on users and permissions.