DBAtlas · Database operations atlas

List users / roles

Oracle

SELECT username, account_status, default_tablespace, created
FROM dba_users
ORDER BY username;

account_status shows LOCKED/EXPIRED states. For roles, use dba_roles.

PostgreSQL

SELECT rolname, rolsuper, rolcanlogin, rolvaliduntil
FROM pg_roles
ORDER BY rolname;
-- Shortcut (psql): \du

In PostgreSQL a user is a role with the LOGIN attribute; rolcanlogin distinguishes it.

MySQL

SELECT user, host, account_locked, password_expired
FROM mysql.user
ORDER BY user;

In MySQL an identity is a user + host pair ('app'@'%' and 'app'@'localhost' are different).

SQL Server

-- Server logins:
SELECT name, type_desc, is_disabled FROM sys.server_principals
WHERE type IN ('S','U','G');
-- Database users:
SELECT name, type_desc FROM sys.database_principals
WHERE type IN ('S','U','G');

A login is server-level, a user is database-level; the two are mapped by SID.

MongoDB

// Users in the current database:
db.getUsers()
// All users in the system: use admin; db.system.users.find({}, {user:1, db:1, roles:1})

Users are defined in the database where they were created (authenticationDatabase).

Redis

ACL LIST
# Names only: ACL USERS
# Your own identity: ACL WHOAMI

The Redis 6+ ACL system. Before that there was a single 'default' user and requirepass.

Open in DBAtlas →