Show all MySQL users:
mysql> SELECT user FROM mysql.user;
List only unique user names:
mysql> SELECT DISTINCT user FROM mysql.user;
Show MySQL users and hosts they are allowed to connect from:
mysql> SELECT user,host FROM mysql.user;
Show MySQL users, their passwords and hosts:
mysql> SELECT user,host,password FROM mysql.user;
in MySQL 5.7 and higher:
mysql> SELECT host,user,authentication_string FROM mysql.user;
Show privileges granted to the current MySQL user:
mysql> SHOW GRANTS;
Show privileges granted to the MySQL user (if you don’t specify a host for the user name, MySQL assumes % as the host):
mysql> SHOW GRANTS FOR 'user_name';
Show privileges granted to a particular MySQL user account from a given host:
mysql> SHOW GRANTS FOR 'user_name'@'host';
– e.g. –
mysql> SHOW GRANTS FOR 'root'@'localhost'; mysql> SHOW GRANTS FOR 'root'@'%'; mysql> SHOW GRANTS FOR 'admin'@'192.168.0.1';