Firstly, get a list of MySQL user accounts, using MySQL.user table. You can use select user column from MySQL.user table to get a list of MySQL user accounts.
The query is as follows −
mysql> select user from MySQL.user;
The following output displays all the users −
+------------------+ | user | +------------------+ | Manish | | mysql.infoschema | | mysql.session | | mysql.sys | | root | | am | +------------------+ 6 rows in set (0.06 sec)
Now you can get a list of host from MySQL.user table. There is host column present in MySQL.user table.
The query is as follows −
mysql> select user,host from MySQL.user;
The following output displays users and host −
+------------------+-----------+ | user | host | +------------------+-----------+ | Manish | % | | mysql.infoschema | % | | mysql.session | % | | mysql.sys | % | | root | % | | am | localhost | +------------------+-----------+ 6 rows in set (0.00 sec)