To get the list of MySQL user accounts, we can use “SELECT USER”.
The following is the query to display the list.
SELECT User FROM mysql.user;
Here is the output.
+------------------+ | User | +------------------+ | John | | Mac | | Manish | | mysql.infoschema | | mysql.session | | mysql.sys | | root | | am | +------------------+ 8 rows in set (0.00 sec)
The above output displays all the user accounts. Here is the query that gives corressponding host.
mysql> select User,Host from mysql.user;
The following is the output.
+------------------+-----------+ | User | Host | +------------------+-----------+ | John | % | | Mac | % | | Manish | % | | mysql.infoschema | % | | mysql.session | % | | mysql.sys | % | | root | % | | am | localhost | +------------------+-----------+ 8 rows in set (0.00 sec)