psql -d postgres -c "ALTER USER app PASSWORD 'newpass';"

Category: Databases & SQL

psql -d postgres -c "ALTER USER app PASSWORD 'newpass';"

Change a role's password

Changes the role's password, taking effect immediately for new logins; existing sessions keep running. Wrap the new value in single quotes inside the SQL string, or use \password interactively to avoid typing it in plain sight.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.