bestlong 怕失憶論壇's Archiver

bestlong 發表於 2010-5-30 00:17

忘記 PostgreSQL 資料庫的管理者密碼該如何重新設定?

若是因為太久沒有使用而忘記 PostgreSQL 資料庫的管理者 postgres 帳號的密碼, 可以用下列的過程來重新設定:

修改用戶端認證設定檔 pg_hba.conf 將原來的 local 設定給註解掉, 例如:

#local all all XXXX

增加一行設定

local all all trust

存檔後重新啟動 postgresql 服務後就可以在主機上免密碼登入[code]
[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 ~]#
[/code]然後再還原 pg_hba.conf 的設定與重新啟動 postgresql 服務, 以回復到原來的安全性
頁: [1]

Powered by Discuz! X1.5 Archiver   © 2001-2010 Comsenz Inc.