password_encryption
Read PG 18 manual ↗When a password is specified in CREATE ROLE or ALTER ROLE, this parameter determines the algorithm to use to encrypt the password.
- Type
- enum
- Context
- user
- Measured default
- scram-sha-256
- Unit
- —
- Metadata snapshot
- 18
- Allowed values
- md5, scram-sha-256
Definition PG 18 manual
When a password is specified in CREATE ROLE or ALTER ROLE, this parameter determines the algorithm to use to encrypt the password. Possible values are scram-sha-256, which will encrypt the password with SCRAM-SHA-256, and md5, which stores the password as an MD5 hash. The default is scram-sha-256.
Note that older clients might lack support for the SCRAM authentication mechanism, and hence not work with passwords encrypted with SCRAM-SHA-256. See Section 20.5 for more details.
Support for MD5-encrypted passwords is deprecated and will be removed in a future release of PostgreSQL. Refer to Section 20.5 for details about migrating to another password type.
Measured default history
| Version interval | Default |
|---|---|
| 9.0 – 9.6 | on |
| 10 – 13 | md5 |
| 14 – 19 | scram-sha-256 |
Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗
How it works
password_encryption chooses the algorithm for encrypting passwords. It affects secrets generated by CREATE ROLE, ALTER ROLE, and password-setting commands; existing stored secrets are not rehashed automatically.
password_encryption is a USER-context setting. An authorized role can change it for a session, while ALTER ROLE or ALTER DATABASE can establish a default for future sessions.
The final authentication path combines this setting with pg_hba.conf, role attributes, credential material, client capabilities, and sometimes operating-system identity services.
Operational considerations
Changing password_encryption in one session and assuming role defaults, database defaults, or other pooled sessions changed with it.
Changing one authentication setting without testing pg_hba.conf ordering, existing secrets, mappings, and every client library.
Weakening identity policy to solve connection churn or CPU cost that should be addressed with pooling and capacity planning.
Changing the algorithm and assuming existing role secrets are automatically converted.
Workload guidance
OLAP: Apply the same security baseline to analytical access; isolate any legacy client exception to a dedicated role and a dated migration plan.
OLTP: Set password_encryption from the authentication architecture and security policy, not workload throughput. Test every driver, identity mapping, failover path, and credential-rotation procedure.
SMALL: Prefer the current secure default for password_encryption. Avoid weakening authentication to save marginal CPU on a small node; reduce connection churn with pooling instead.
Version history 6
- PG 17 → 18changed
- PG 16 → 17changed
- PG 13 → 14changed
- PG 10 → 11changed
- PG 9.6 → 10changed
- PG 9.0 → 9.1changed
Related entries
Further reading
Definition snapshot: english-manuals:170f812ad29d6a075c62400f70d… · English manual source