MySQL stores the list of users in the mysql.user table. List of all databases are available in the mysql.db table.

Show list of MySQL users

1
2
3
4
5
# Show list of all users
select user from mysql.user;

# Show list of users assigned to a particular database
select user from mysql.db where db='databasename';

Show list of databases for a user

1
2
# Show a list of databases a particular user can manage
select db from mysql.db where user='dbusername';

Delete a user

1
2
# Delete an user from all MySQL users. 'dbusername' must exist.
drop user dbusername@localhost;