List all MySQL Users
To get list of all users in MySQL login to MySQL server under
root user (or any user with administrative privileges) then run the following command:
> select * from mysql.user \G;
\Gat the end of the command will format the result before output it.
To display only the name of the user:
> select User from mysql.user \G;
Understand The Command
In MySQL, all users (or accounts) are stored in the
user table of
mysql database. To view this table structure, first select the database:
> use mysql;
Then run the
> describe user;
You'll see MySQL returns a list of fields (or columns), types associated with each column and other information. Feel free to explore data of those columns by modify the
command query in the previous section.