select * from mysql.user;
#or for less data
select user, host from mysql.user;
//To show all data use following query
select * from mysql.user;
// To show user and host use following query
select User,Host from mysql.user;
mysql> select host, user, password from mysql.user;
SELECT User FROM mysql.user;
sudo mysql # first run this command to login mysql
select user, host from mysql.user;
// login to mysql as root
mysql -u root -p
// use mysql database
use mysql;
// list users
select user,host from user;
#display all user data
select * from mysql.user;
#display username and host
select user, host from mysql.user;
mysql> select * from mysql.user;
# List All Unique Usernames
SELECT DISTINCT User FROM mysql.user;
# List All Usernames + Hostnames;
SELECT User,Host FROM mysql.user;
mysql> select user,host from user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| admin | % |
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
$ mysql -u root -p //login with root
Enter password: *********
mysql> use mysql; //use mysql
Database changed.
mysql> SELECT user FROM user; //show userlist