Listing MySQL users might seem like a routine task, but it’s one with real security stakes. Whether you're auditing access, checking privileges, or onboarding new users, even a small misstep can expose your database to risk.
This guide walks you through how to list MySQL users using SQL queries and GUI tools like Workbench and phpMyAdmin. You'll also learn how to check user privileges, manage accounts, and avoid common security pitfalls, like using wildcard hosts or root for applications.
And because user access is a critical part of your security posture, we show you how to simplify MySQL access management with centralized controls, session logging, and just-in-time access, so you always know who’s connecting, what they can do, and when their access ends.
User information for MySQL databases usually exists in the mysql.user table. This information includes the username, host, authentication string (password), user’s privileges, and authentication plugins.
You can inspect the mysql.user table to see this data using the command below:
DESC mysql.user;
It’s short for the DESCRIBE mysql.user; command. The output for this command will usually include columns such as field, type, null, key, default, and extra.
Note: The DESC mysql.user; command is also useful for understanding the schema of the mysql.user table before querying more fields.
Before we look at the various methods, it’s worth noting that there are several prerequisites to list users in a MySQL database. For one, you must have access to a terminal window or the command line. Secondly, your user account should have root or sudo privileges.
This is the most commonly used method because it directly queries the mysql.user table. You can use this basic syntax:
SELECT user FROM mysql.user;
You should see a list similar to the one below:
+------------------+
| user |
+------------------+
| debian-test-user |
| claire |
| sean |
| root |
| joe |
| ray |
+--------------------+
6 rows in set (0.03 sec)
If you want a more detailed view of the users, such as their hosts and passwords, you can edit the basic syntax:
SELECT User, Host, authentication_string FROM mysql.user;
Note: In older versions than MySQL 8.0+, the authentication_string column in the command was noted as Password.
The above syntax would display a list of users similar to this:
+-----------+------------+--------------------------+
| User | Host | Password |
+-----------+------------+--------------------------+
| debian-test-user | localhost | *QGRO60573BH343U9OJOFNQUUUIBFBQEY13009G |
| claire | % | *PUHUD JGCYXG6T7AW3EE;KPMMAWRE9J8W4YUNVG |
| sean | 127.0.0.1 | *2BkdnVZESR8ITGQE AFDMIOJRJY08WUTSHNMSFEN |
| root | localhost | *MXCOVJPZJPSJINSRHX78HSRNISFHYRW38743UIHA |
| joe | % | *9CKNAGZBJBZJWTE754437UGJADMBBSGEFKGKYBE |
| ray | localhost | *SJLHKA3HI8Y845YHQYRBNMXFK09ET65EKIYT774 |
+-----------+-----------+---------------------------+
6 rows in set (0.20 sec)
If you want to return specific results with the SELECT command, you can use the WHERE option.
Take, for instance, this command:
SELECT User FROM mysql.user WHERE Host = 'localhost';
This tells the system to list MySQL users where the host column equals 'localhost'
So, from the table above, the list would only contain debian-test-user, root, and ray, as shown below:
+-------------------+-----------+
| User | Host |
+-------------------+-----------+
| debian-test-user | localhost |
| root | localhost |
| ray | localhost |
+------------------+-----------+
3 rows in set (0.01 sec)
You can also filter results using pattern matching with the LIKE option. This tells the system to display users with a specific pattern. The LIKE option uses wildcard characters such as:
For instance, the command SELECT User FROM mysql.user WHERE User LIKE 'c%'; will list all the users whose names start with the letter c.
Another example:
SELECT User FROM mysql.user WHERE User LIKE '____'; will list users whose names have only four dd.
Dealing with manual queries can be slow and time-consuming, especially if you just started working with MySQL. If that’s the case, you can use Graphical User Interfaces (GUI) MySQL SHOW USERS alternatives. GUIs provide an easy way to list users by letting you perform actions like point, click, drop, and select within the database.
This method requires that you install phpMyAdmin. [A1] Once installed,
This is another visual interface you can leverage to manage users and view permissions. It’s useful for teams and enterprise environments.
After listing users on your MySQL database, you may also need to check the privileges and permissions they possess for security purposes.
To see the user privileges for just one user, type this:
SHOW GRANTS FOR 'username'@'host';
You can use this command for auditing purposes or to replicate access levels.
To see the privileges for all users on the database, type this:
SELECT CONCAT('SHOW GRANTS FOR \'', user, '\'@\'', host, '\';') FROM mysql.user;
NOTE: This will generate a batch of grant statements for each user on your database. You can then run each of the SHOW GRANTS statements to view the privileges each user has.
There are also several important actions you should understand alongside listing MySQL users.
For instance, if you want to create or add a new user in your database, you can use this command:
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
You can also remove a user easily:
DROP USER 'username'@'host';
If you need to change the password and host of a user as part of routine security management, you can run this command:
ALTER USER 'username'@'host' IDENTIFIED BY 'newpassword';
For security purposes, you may need to lock a user account. To do so, use the following command:
ALTER USER 'username'@'host' ACCOUNT LOCK;
Should you need to reactivate it, the following command will do so:
ALTER USER 'username'@'host' ACCOUNT UNLOCK;
When it comes to database user management, security should be your number one priority. It’s vital to adopt measures that block malicious actors and reduce vulnerabilities:
Listing MySQL users isn’t just an admin task—it’s a security checkpoint. Every user, host, and privilege entry represents a potential access point. Missteps like wildcard hosts, overprivileged accounts, or stale users can expose your database to serious risk.
Delinea removes that risk by giving you centralized visibility, tight access control, and full audit trails across every database connection—no manual queries or guesswork needed.
mysql.userSkip the CLI scripts, GUIs, and user audits. Delinea gives you real-time, secure control over MySQL access—without the operational overhead.
Book a demo to see how Delinea transforms database access into a secure, manageable, and auditable process.