簡體   English   中英

psql:致命:用戶“postgres”postgresql 版本 10 的密碼驗證失敗

[英]psql: FATAL: password authentication failed for user "postgres" postgresql version 10

我最近在 linux red hat 上安裝了 Postgre 版本 10。 我正在嘗試配置 psql 在訪問數據庫時會提示用戶輸入密碼。 將所有內容更改為 scram-sha-256 后。 訪問 psql 時出現此錯誤

psql: FATAL:  password authentication failed for user "postgres"

這是我的 pg_hba.conf: 在此處輸入圖像描述

知道如何解決這個問題嗎? 謝謝!

Postgres 默認存儲密碼md5格式。 如果要更改密碼加密,則必須遵循以下解決方案:

PS:在開始之前,您必須將pg_hba.conf文件的身份驗證方法撤消到md5

  1. 編輯postgresql.conf並將password_encryption更改為
password_encryption = scram-sha-256
  1. 重啟 Postgres 服務(或重新加載服務)

  2. 重置用戶密碼

# if use psql cli
\password <user>

# If use SQL command
alter user <user> with password '<password>';
  1. 更新所有密碼后,您應該將pg_hba.conf身份驗證方法更改為scram-sha-256並再次重置服務

參考: 關於升級 postgres 密碼認證的信息

我知道在需要為psql識別密碼時設置新密碼(在 CMD 中)是解決我的問題:

 set PGPASSWORD= #type here the password you want to set

設置后,您編寫以下內容(例如):

psql -h 188.81.81.92 -U postgres -d postgres -p 5432

其中-h代表主機,-U代表用戶,-d代表數據庫根目錄,-p代表端口,使用postgreSQL語言。

在 windows 中,可能會出現問題:錯誤:連接到服務器 (...),可以通過鍵入以下內容來解決:

C:\\Program Files\\PostgreSQL\\14\\bin\\psql.exe

也就是說,您打開文件psql.exe ,它會正常工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM