{"Entry":{"collection":"auth","key":"password","name":"password","aliases":[],"metadata":{"aliases":[],"category":"Password authentication","content_hash":"ca4142941cca107dedb2207dd79efb497e11713f6697f5facb14997513c89f28","imported_at":"2026-09-30T00:40:33.323389+08:00","name":"password","name_zh":"","slug":"password","summary":"Require the client to supply an unencrypted password for authentication. Since the password is sent in clear text over the network, this should not be used on untrusted networks. See Section 20.5 for details."}},"Definition":{"Collection":"auth","Key":"password","SourceDatabase":"center","Version":"18","SourceTable":"authentication_method","SourceKey":"password","SourceRevision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","Facts":{"aliases":[],"attributes":{"configuration":"pg_hba.conf","inventory":"User-visible source authentication method","method":"password"},"comparison_data":{"documented_option_names":["md5","password","scram-sha-256"],"method":"password"},"comparison_hash":"d4a07ed4f297699ecd061181bcc656e57ea443c94b1d7536a172c08865099daf","description":["Require the client to supply an unencrypted password for authentication. Since the password is sent in clear text over the network, this should not be used on untrusted networks. See Section 20.5 for details."],"facts":[{"label":"Method","value":"password"},{"label":"Configuration","value":"pg_hba.conf"},{"label":"Inventory","value":"User-visible source authentication method"}],"manual_html":"\u003cdiv class=\"sect1\" id=\"AUTH-PASSWORD\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch2 class=\"title\"\u003e20.5. Password Authentication \u003c/h2\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThere are several password-based authentication methods. These methods operate similarly but differ in how the users' passwords are stored on the server and how the password provided by a client is sent across the connection.\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003escram-sha-256\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe method \u003ccode class=\"literal\"\u003escram-sha-256\u003c/code\u003e performs SCRAM-SHA-256 authentication, as described in \u003ca class=\"ulink\" href=\"https://datatracker.ietf.org/doc/html/rfc7677\"\u003eRFC 7677\u003c/a\u003e. It is a challenge-response scheme that prevents password sniffing on untrusted connections and supports storing passwords on the server in a cryptographically hashed form that is thought to be secure.\u003c/p\u003e\n\u003cp\u003eThis is the most secure of the currently provided methods, but it is not supported by older client libraries.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003emd5\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe method \u003ccode class=\"literal\"\u003emd5\u003c/code\u003e uses a custom less secure challenge-response mechanism. It prevents password sniffing and avoids storing passwords on the server in plain text but provides no protection if an attacker manages to steal the password hash from the server. Also, the MD5 hash algorithm is nowadays no longer considered secure against determined attacks.\u003c/p\u003e\n\u003cp\u003eTo ease transition from the \u003ccode class=\"literal\"\u003emd5\u003c/code\u003e method to the newer SCRAM method, if \u003ccode class=\"literal\"\u003emd5\u003c/code\u003e is specified as a method in \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e but the user's password on the server is encrypted for SCRAM (see below), then SCRAM-based authentication will automatically be chosen instead.\u003c/p\u003e\n\u003cdiv class=\"warning\"\u003e\n\u003ch3 class=\"title\"\u003eWarning\u003c/h3\u003e\n\u003cp\u003eSupport for MD5-encrypted passwords is deprecated and will be removed in a future release of \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e. Refer to the text below for details about migrating to another password type.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003epassword\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe method \u003ccode class=\"literal\"\u003epassword\u003c/code\u003e sends the password in clear-text and is therefore vulnerable to password \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003esniffing\u003c/span\u003e”\u003c/span\u003e attacks. It should always be avoided if possible. If the connection is protected by SSL encryption then \u003ccode class=\"literal\"\u003epassword\u003c/code\u003e can be used safely, though. (Though SSL certificate authentication might be a better choice if one is depending on using SSL).\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003e\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e database passwords are separate from operating system user passwords. The password for each database user is stored in the \u003ccode class=\"literal\"\u003epg_authid\u003c/code\u003e system catalog. Passwords can be managed with the SQL commands \u003ca class=\"xref\" href=\"/docs/18/sql-createrole.html\" title=\"CREATE ROLE\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE ROLE\u003c/span\u003e\u003c/a\u003e and \u003ca class=\"xref\" href=\"/docs/18/sql-alterrole.html\" title=\"ALTER ROLE\"\u003e\u003cspan class=\"refentrytitle\"\u003eALTER ROLE\u003c/span\u003e\u003c/a\u003e, e.g., \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eCREATE ROLE foo WITH LOGIN PASSWORD 'secret'\u003c/code\u003e\u003c/strong\u003e, or the \u003cspan class=\"application\"\u003epsql\u003c/span\u003e command \u003ccode class=\"literal\"\u003e\\password\u003c/code\u003e. If no password has been set up for a user, the stored password is null and password authentication will always fail for that user.\u003c/p\u003e\n\u003cp\u003eThe availability of the different password-based authentication methods depends on how a user's password on the server is encrypted (or hashed, more accurately). This is controlled by the configuration parameter \u003ca class=\"xref\" href=\"/docs/18/runtime-config-connection.html#GUC-PASSWORD-ENCRYPTION\"\u003epassword_encryption\u003c/a\u003e at the time the password is set. If a password was encrypted using the \u003ccode class=\"literal\"\u003escram-sha-256\u003c/code\u003e setting, then it can be used for the authentication methods \u003ccode class=\"literal\"\u003escram-sha-256\u003c/code\u003e and \u003ccode class=\"literal\"\u003epassword\u003c/code\u003e (but password transmission will be in plain text in the latter case). The authentication method specification \u003ccode class=\"literal\"\u003emd5\u003c/code\u003e will automatically switch to using the \u003ccode class=\"literal\"\u003escram-sha-256\u003c/code\u003e method in this case, as explained above, so it will also work. If a password was encrypted using the \u003ccode class=\"literal\"\u003emd5\u003c/code\u003e setting, then it can be used only for the \u003ccode class=\"literal\"\u003emd5\u003c/code\u003e and \u003ccode class=\"literal\"\u003epassword\u003c/code\u003e authentication method specifications (again, with the password transmitted in plain text in the latter case). (Previous PostgreSQL releases supported storing the password on the server in plain text. This is no longer possible.) To check the currently stored password hashes, see the system catalog \u003ccode class=\"literal\"\u003epg_authid\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eTo upgrade an existing installation from \u003ccode class=\"literal\"\u003emd5\u003c/code\u003e to \u003ccode class=\"literal\"\u003escram-sha-256\u003c/code\u003e, after having ensured that all client libraries in use are new enough to support SCRAM, set \u003ccode class=\"literal\"\u003epassword_encryption = 'scram-sha-256'\u003c/code\u003e in \u003ccode class=\"filename\"\u003epostgresql.conf\u003c/code\u003e, make all users set new passwords, and change the authentication method specifications in \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e to \u003ccode class=\"literal\"\u003escram-sha-256\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e","manual_path":"/docs/18/auth-password.html","related":[],"release":{"catalog_fingerprint":"65c93d6048ef30e61023a84f9680fa6a92b1c383b7eb226741170077eb078502","channel":"stable","label":"18.6","major":"18","ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sections":[],"signature":"","sources":[{"label":"Matching PostgreSQL source archive","sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"label":"PostgreSQL 18 English manual","path":"auth-password.html","sha256":"89d87aa104ffde4d6ddb753032794cc5924db149179845d97788e0999e0971c1","url":"/docs/18/auth-password.html"},{"label":"PostgreSQL 18 English manual","path":"auth-pg-hba-conf.html","sha256":"6340d4abea2e0a3482afc31bcd1599a0fa10dc28a6f1e05d79ba831e2dd0b4c9","url":"/docs/18/auth-pg-hba-conf.html"}],"tables":[{"columns":[{"key":"name","label":"Option or term"},{"key":"description","label":"Meaning"}],"key":"method-options","rows":[{"description":"The method scram-sha-256 performs SCRAM-SHA-256 authentication, as described in RFC 7677 . It is a challenge-response scheme that prevents password sniffing on untrusted connections and supports storing passwords on the server in a cryptographically hashed form that is thought to be secure. This is the most secure of the currently provided methods, but it is not supported by older client libraries.","name":"scram-sha-256"},{"description":"The method md5 uses a custom less secure challenge-response mechanism. It prevents password sniffing and avoids storing passwords on the server in plain text but provides no protection if an attacker manages to steal the password hash from the server. Also, the MD5 hash algorithm is nowadays no longer considered secure against determined attacks. To ease transition from the md5 method to the newer SCRAM method, if md5 is specified as a method in pg_hba.conf but the user's password on the server is encrypted for SCRAM (see below), then SCRAM-based authentication will automatically be chosen instead. Warning Support for MD5-encrypted passwords is deprecated and will be removed in a future release of PostgreSQL . Refer to the text below for details about migrating to another password type.","name":"md5"},{"description":"The method password sends the password in clear-text and is therefore vulnerable to password “ sniffing ” attacks. It should always be avoided if possible. If the connection is protected by SSL encryption then password can be used safely, though. (Though SSL certificate authentication might be a better choice if one is depending on using SSL).","name":"password"}],"title":"Documented method options and alternatives"}]},"ManualEvidence":{"manual_path":"/docs/18/auth-password.html","release":{"catalog_fingerprint":"65c93d6048ef30e61023a84f9680fa6a92b1c383b7eb226741170077eb078502","channel":"stable","label":"18.6","major":"18","ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sources":[{"label":"Matching PostgreSQL source archive","sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"label":"PostgreSQL 18 English manual","path":"auth-password.html","sha256":"89d87aa104ffde4d6ddb753032794cc5924db149179845d97788e0999e0971c1","url":"/docs/18/auth-password.html"},{"label":"PostgreSQL 18 English manual","path":"auth-pg-hba-conf.html","sha256":"6340d4abea2e0a3482afc31bcd1599a0fa10dc28a6f1e05d79ba831e2dd0b4c9","url":"/docs/18/auth-pg-hba-conf.html"}]},"MeasuredEvidence":{}},"Text":{"Collection":"auth","Key":"password","SourceDatabase":"center","Version":"18","Locale":"en","Title":"password","Summary":"Require the client to supply an unencrypted password for authentication. Since the password is sent in clear text over the network, this should not be used on untrusted networks. See Section 20.5 for details.","BodyHTML":"\u003cdiv id=\"AUTH-PASSWORD\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch2\u003e20.5. Password Authentication \u003c/h2\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThere are several password-based authentication methods. These methods operate similarly but differ in how the users\u0026#39; passwords are stored on the server and how the password provided by a client is sent across the connection.\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003escram-sha-256\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe method \u003ccode\u003escram-sha-256\u003c/code\u003e performs SCRAM-SHA-256 authentication, as described in \u003ca href=\"https://datatracker.ietf.org/doc/html/rfc7677\" rel=\"nofollow\"\u003eRFC 7677\u003c/a\u003e. It is a challenge-response scheme that prevents password sniffing on untrusted connections and supports storing passwords on the server in a cryptographically hashed form that is thought to be secure.\u003c/p\u003e\n\u003cp\u003eThis is the most secure of the currently provided methods, but it is not supported by older client libraries.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003emd5\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe method \u003ccode\u003emd5\u003c/code\u003e uses a custom less secure challenge-response mechanism. It prevents password sniffing and avoids storing passwords on the server in plain text but provides no protection if an attacker manages to steal the password hash from the server. Also, the MD5 hash algorithm is nowadays no longer considered secure against determined attacks.\u003c/p\u003e\n\u003cp\u003eTo ease transition from the \u003ccode\u003emd5\u003c/code\u003e method to the newer SCRAM method, if \u003ccode\u003emd5\u003c/code\u003e is specified as a method in \u003ccode\u003epg_hba.conf\u003c/code\u003e but the user\u0026#39;s password on the server is encrypted for SCRAM (see below), then SCRAM-based authentication will automatically be chosen instead.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eWarning\u003c/h3\u003e\n\u003cp\u003eSupport for MD5-encrypted passwords is deprecated and will be removed in a future release of \u003cspan\u003ePostgreSQL\u003c/span\u003e. Refer to the text below for details about migrating to another password type.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003epassword\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe method \u003ccode\u003epassword\u003c/code\u003e sends the password in clear-text and is therefore vulnerable to password \u003cspan\u003e“\u003cspan\u003esniffing\u003c/span\u003e”\u003c/span\u003e attacks. It should always be avoided if possible. If the connection is protected by SSL encryption then \u003ccode\u003epassword\u003c/code\u003e can be used safely, though. (Though SSL certificate authentication might be a better choice if one is depending on using SSL).\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003e\u003cspan\u003ePostgreSQL\u003c/span\u003e database passwords are separate from operating system user passwords. The password for each database user is stored in the \u003ccode\u003epg_authid\u003c/code\u003e system catalog. Passwords can be managed with the SQL commands \u003ca href=\"/docs/18/sql-createrole.html\" title=\"CREATE ROLE\" rel=\"nofollow\"\u003e\u003cspan\u003eCREATE ROLE\u003c/span\u003e\u003c/a\u003e and \u003ca href=\"/docs/18/sql-alterrole.html\" title=\"ALTER ROLE\" rel=\"nofollow\"\u003e\u003cspan\u003eALTER ROLE\u003c/span\u003e\u003c/a\u003e, e.g., \u003cstrong\u003e\u003ccode\u003eCREATE ROLE foo WITH LOGIN PASSWORD \u0026#39;secret\u0026#39;\u003c/code\u003e\u003c/strong\u003e, or the \u003cspan\u003epsql\u003c/span\u003e command \u003ccode\u003e\\password\u003c/code\u003e. If no password has been set up for a user, the stored password is null and password authentication will always fail for that user.\u003c/p\u003e\n\u003cp\u003eThe availability of the different password-based authentication methods depends on how a user\u0026#39;s password on the server is encrypted (or hashed, more accurately). This is controlled by the configuration parameter \u003ca href=\"/docs/18/runtime-config-connection.html#GUC-PASSWORD-ENCRYPTION\" rel=\"nofollow\"\u003epassword_encryption\u003c/a\u003e at the time the password is set. If a password was encrypted using the \u003ccode\u003escram-sha-256\u003c/code\u003e setting, then it can be used for the authentication methods \u003ccode\u003escram-sha-256\u003c/code\u003e and \u003ccode\u003epassword\u003c/code\u003e (but password transmission will be in plain text in the latter case). The authentication method specification \u003ccode\u003emd5\u003c/code\u003e will automatically switch to using the \u003ccode\u003escram-sha-256\u003c/code\u003e method in this case, as explained above, so it will also work. If a password was encrypted using the \u003ccode\u003emd5\u003c/code\u003e setting, then it can be used only for the \u003ccode\u003emd5\u003c/code\u003e and \u003ccode\u003epassword\u003c/code\u003e authentication method specifications (again, with the password transmitted in plain text in the latter case). (Previous PostgreSQL releases supported storing the password on the server in plain text. This is no longer possible.) To check the currently stored password hashes, see the system catalog \u003ccode\u003epg_authid\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eTo upgrade an existing installation from \u003ccode\u003emd5\u003c/code\u003e to \u003ccode\u003escram-sha-256\u003c/code\u003e, after having ensured that all client libraries in use are new enough to support SCRAM, set \u003ccode\u003epassword_encryption = \u0026#39;scram-sha-256\u0026#39;\u003c/code\u003e in \u003ccode\u003epostgresql.conf\u003c/code\u003e, make all users set new passwords, and change the authentication method specifications in \u003ccode\u003epg_hba.conf\u003c/code\u003e to \u003ccode\u003escram-sha-256\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e","SourceRevision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","ContentHash":"6b45b2100e3b8e214b20ebfc325290ac096f302e7f1d0e1c79b48fc1bb07518f","Payload":{"description":["Require the client to supply an unencrypted password for authentication. Since the password is sent in clear text over the network, this should not be used on untrusted networks. See Section 20.5 for details."],"manual_html":"\u003cdiv class=\"sect1\" id=\"AUTH-PASSWORD\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch2 class=\"title\"\u003e20.5. Password Authentication \u003c/h2\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eThere are several password-based authentication methods. These methods operate similarly but differ in how the users' passwords are stored on the server and how the password provided by a client is sent across the connection.\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003escram-sha-256\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe method \u003ccode class=\"literal\"\u003escram-sha-256\u003c/code\u003e performs SCRAM-SHA-256 authentication, as described in \u003ca class=\"ulink\" href=\"https://datatracker.ietf.org/doc/html/rfc7677\"\u003eRFC 7677\u003c/a\u003e. It is a challenge-response scheme that prevents password sniffing on untrusted connections and supports storing passwords on the server in a cryptographically hashed form that is thought to be secure.\u003c/p\u003e\n\u003cp\u003eThis is the most secure of the currently provided methods, but it is not supported by older client libraries.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003emd5\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe method \u003ccode class=\"literal\"\u003emd5\u003c/code\u003e uses a custom less secure challenge-response mechanism. It prevents password sniffing and avoids storing passwords on the server in plain text but provides no protection if an attacker manages to steal the password hash from the server. Also, the MD5 hash algorithm is nowadays no longer considered secure against determined attacks.\u003c/p\u003e\n\u003cp\u003eTo ease transition from the \u003ccode class=\"literal\"\u003emd5\u003c/code\u003e method to the newer SCRAM method, if \u003ccode class=\"literal\"\u003emd5\u003c/code\u003e is specified as a method in \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e but the user's password on the server is encrypted for SCRAM (see below), then SCRAM-based authentication will automatically be chosen instead.\u003c/p\u003e\n\u003cdiv class=\"warning\"\u003e\n\u003ch3 class=\"title\"\u003eWarning\u003c/h3\u003e\n\u003cp\u003eSupport for MD5-encrypted passwords is deprecated and will be removed in a future release of \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e. Refer to the text below for details about migrating to another password type.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003epassword\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe method \u003ccode class=\"literal\"\u003epassword\u003c/code\u003e sends the password in clear-text and is therefore vulnerable to password \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003esniffing\u003c/span\u003e”\u003c/span\u003e attacks. It should always be avoided if possible. If the connection is protected by SSL encryption then \u003ccode class=\"literal\"\u003epassword\u003c/code\u003e can be used safely, though. (Though SSL certificate authentication might be a better choice if one is depending on using SSL).\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003e\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e database passwords are separate from operating system user passwords. The password for each database user is stored in the \u003ccode class=\"literal\"\u003epg_authid\u003c/code\u003e system catalog. Passwords can be managed with the SQL commands \u003ca class=\"xref\" href=\"/docs/18/sql-createrole.html\" title=\"CREATE ROLE\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE ROLE\u003c/span\u003e\u003c/a\u003e and \u003ca class=\"xref\" href=\"/docs/18/sql-alterrole.html\" title=\"ALTER ROLE\"\u003e\u003cspan class=\"refentrytitle\"\u003eALTER ROLE\u003c/span\u003e\u003c/a\u003e, e.g., \u003cstrong class=\"userinput\"\u003e\u003ccode\u003eCREATE ROLE foo WITH LOGIN PASSWORD 'secret'\u003c/code\u003e\u003c/strong\u003e, or the \u003cspan class=\"application\"\u003epsql\u003c/span\u003e command \u003ccode class=\"literal\"\u003e\\password\u003c/code\u003e. If no password has been set up for a user, the stored password is null and password authentication will always fail for that user.\u003c/p\u003e\n\u003cp\u003eThe availability of the different password-based authentication methods depends on how a user's password on the server is encrypted (or hashed, more accurately). This is controlled by the configuration parameter \u003ca class=\"xref\" href=\"/docs/18/runtime-config-connection.html#GUC-PASSWORD-ENCRYPTION\"\u003epassword_encryption\u003c/a\u003e at the time the password is set. If a password was encrypted using the \u003ccode class=\"literal\"\u003escram-sha-256\u003c/code\u003e setting, then it can be used for the authentication methods \u003ccode class=\"literal\"\u003escram-sha-256\u003c/code\u003e and \u003ccode class=\"literal\"\u003epassword\u003c/code\u003e (but password transmission will be in plain text in the latter case). The authentication method specification \u003ccode class=\"literal\"\u003emd5\u003c/code\u003e will automatically switch to using the \u003ccode class=\"literal\"\u003escram-sha-256\u003c/code\u003e method in this case, as explained above, so it will also work. If a password was encrypted using the \u003ccode class=\"literal\"\u003emd5\u003c/code\u003e setting, then it can be used only for the \u003ccode class=\"literal\"\u003emd5\u003c/code\u003e and \u003ccode class=\"literal\"\u003epassword\u003c/code\u003e authentication method specifications (again, with the password transmitted in plain text in the latter case). (Previous PostgreSQL releases supported storing the password on the server in plain text. This is no longer possible.) To check the currently stored password hashes, see the system catalog \u003ccode class=\"literal\"\u003epg_authid\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eTo upgrade an existing installation from \u003ccode class=\"literal\"\u003emd5\u003c/code\u003e to \u003ccode class=\"literal\"\u003escram-sha-256\u003c/code\u003e, after having ensured that all client libraries in use are new enough to support SCRAM, set \u003ccode class=\"literal\"\u003epassword_encryption = 'scram-sha-256'\u003c/code\u003e in \u003ccode class=\"filename\"\u003epostgresql.conf\u003c/code\u003e, make all users set new passwords, and change the authentication method specifications in \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e to \u003ccode class=\"literal\"\u003escram-sha-256\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e","related":[],"sections":[],"tables":[{"columns":[{"key":"name","label":"Option or term"},{"key":"description","label":"Meaning"}],"key":"method-options","rows":[{"description":"The method scram-sha-256 performs SCRAM-SHA-256 authentication, as described in RFC 7677 . It is a challenge-response scheme that prevents password sniffing on untrusted connections and supports storing passwords on the server in a cryptographically hashed form that is thought to be secure. This is the most secure of the currently provided methods, but it is not supported by older client libraries.","name":"scram-sha-256"},{"description":"The method md5 uses a custom less secure challenge-response mechanism. It prevents password sniffing and avoids storing passwords on the server in plain text but provides no protection if an attacker manages to steal the password hash from the server. Also, the MD5 hash algorithm is nowadays no longer considered secure against determined attacks. To ease transition from the md5 method to the newer SCRAM method, if md5 is specified as a method in pg_hba.conf but the user's password on the server is encrypted for SCRAM (see below), then SCRAM-based authentication will automatically be chosen instead. Warning Support for MD5-encrypted passwords is deprecated and will be removed in a future release of PostgreSQL . Refer to the text below for details about migrating to another password type.","name":"md5"},{"description":"The method password sends the password in clear-text and is therefore vulnerable to password “ sniffing ” attacks. It should always be avoided if possible. If the connection is protected by SSL encryption then password can be used safely, though. (Though SSL certificate authentication might be a better choice if one is depending on using SSL).","name":"password"}],"title":"Documented method options and alternatives"}]}},"RequestedLocale":"zh-Hans","Fallback":true,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
