DBAtlas · Database operations atlas

Change a user's password

Oracle

ALTER USER app IDENTIFIED BY "New#Pass2";

To unlock a locked account: ALTER USER app ACCOUNT UNLOCK; If the password has expired, the same command resets it.

PostgreSQL

ALTER ROLE app WITH PASSWORD 'New#Pass2';

To keep the password out of the logs, the \password app (psql) meta-command hashes the password on the client side.

MySQL

ALTER USER 'app'@'%' IDENTIFIED BY 'New#Pass2';

Make sure you pick the right host; 'app'@'localhost' is a separate account. ALTER USER takes effect immediately; FLUSH PRIVILEGES is not needed.

SQL Server

ALTER LOGIN app WITH PASSWORD = 'New#Pass2';
-- For a user changing their own password: add OLD_PASSWORD

MUST_CHANGE can force a change at first login: WITH PASSWORD='...' MUST_CHANGE, CHECK_POLICY=ON.

MongoDB

db.changeUserPassword("app", "New#Pass2")

Make sure you have switched to the user's auth database (use mydb).

Redis

# Clear old passwords and set the new one:
ACL SETUSER app resetpass >New#Pass2
# Persistence: ACL SAVE if an aclfile is defined, otherwise CONFIG REWRITE

resetpass removes all existing passwords; > only adds one. For persistence, run ACL SAVE if an aclfile is used, or CONFIG REWRITE if users are defined in redis.conf (ACL SAVE returns an error without an aclfile).

Open in DBAtlas →