Today I Learned

hashrocket A Hashrocket project

Reset Postgres User Password

Resetting a Postgres user's password with alter role is fine, but there is a better way! Try:

\password [ username ]

This changes the password of the specified user, defaulting to the current user. I like this because it prompts you for a password, encrypts it (security!), and sends it to the server as alter role. Your password will not appear as cleartext in the command history, server log, or anywhere else.


h/t Jack Christensen

See More #sql TILs
Looking for help? Hashrocket developers believe that data quality is as important as code quality. We enjoy all the challenges of relational databases, from finding the fastest index, to structuring data to fit the needs of an application. We're eager to share our experiences; check out PG Casts, our series of free PostgreSQL screencasts.