The End of md5 Password Storage Is in Sight
PostgreSQL has moved its default password hashing to scram-sha-256, yet md5 remains available as a password_encryption option. That flexibility is about to disappear, and PostgreSQL 18 marks the beginning of the end.
Starting with PostgreSQL 18, setting password_encryption to md5 and issuing a CREATE/ALTER ROLE/USER command with the WITH PASSWORD option triggers a deprecation warning:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
postgres=# set password_encryption = 'md5'; SET postgres=# CREATE USER test with password '@secure%'; WARNING: setting an MD5-encrypted password DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL. HINT: Refer to the PostgreSQL documentation for details about migrating to another password type. CREATE ROLE postgres=# ALTER ROLE test_role WITH PASSWORD '@too_secure%'; WARNING: setting an MD5-encrypted password DETAIL: MD5 password support is deprecated and will be removed in a future release of PostgreSQL. HINT: Refer to the PostgreSQL documentation for details about migrating to another password type. ALTER ROLE |
Interestingly, changing password_encryption itself to md5 produces no such warning. The explanation is pragmatic: md5 support will be removed in the next major release, so the effort to build an additional notice simply isn't justified.
Silencing the Deprecation Warning
If your environment isn't ready to migrate right away, a new GUC named md5_password_warnings is available. Set to on by default, flipping it to off suppresses these deprecation notices:
|
1 2 3 4 5 6 7 8 9 |
postgres=# show md5_password_warnings; md5_password_warnings ----------------------- on (1 row) postgres=# set md5_password_warnings = off; SET postgres=# ALTER ROLE test_role WITH PASSWORD '@too_secure%'; ALTER ROLE |
Post-MD5 Authentication Strategy
PostgreSQL's recommended password hashing method is scram-sha-256, which is significantly stronger than md5. It currently stands as the default and the sole alternative to md5 for the password_encryption setting.
Steps for migrating from md5 to scram-sha-256
- Verify that all client libraries in use support SCRAM authentication.
- Set
password_encryption = 'scram-sha-256'on the client side and reset the password for every user. - Note that existing md5-encrypted passwords cannot be validated by SCRAM; each user must be assigned a new password during this process.
- Inspect the current password hashes by querying the
pg_authidcatalog to track migration progress. - Once all users are confirmed to have SCRAM-encrypted passwords, update
pg_hba.confto usescram-sha-256as the authentication method. - During a transition, if
pg_hba.confspecifiesmd5but a user's stored password was hashed with SCRAM, PostgreSQL automatically selects thescram-sha-256mechanism for that connection attempt.



