- 註冊時間
- 2006-3-13
- 最後登錄
- 2025-1-10
- 在線時間
- 673 小時
- 閱讀權限
- 200
- 積分
- 417
- 帖子
- 1107
- 精華
- 0
- UID
- 2
  
|
若是因為太久沒有使用而忘記 PostgreSQL 資料庫的管理者 postgres 帳號的密碼, 可以用下列的過程來重新設定:
修改用戶端認證設定檔 pg_hba.conf 將原來的 local 設定給註解掉, 例如:
#local all all XXXX
增加一行設定
local all all trust
存檔後重新啟動 postgresql 服務後就可以在主機上免密碼登入- [root@bestlong ~]# psql -U postgres template1
- Welcome to psql 8.3.7, the PostgreSQL interactive terminal.
- Type: \copyright for distribution terms
- \h for help with SQL commands
- \? for help with psql commands
- \g or terminate with semicolon to execute query
- \q to quit
- template1=# alter user postgres password 'YourNewPassword';
- ALTER ROLE
- template1=# \q
- [root@bestlong ~]#
複製代碼 然後再還原 pg_hba.conf 的設定與重新啟動 postgresql 服務, 以回復到原來的安全性 |
|