bestlong 怕失憶論壇

 

 

搜索
bestlong 怕失憶論壇 論壇 Database - 資料庫 PostgreSQL 忘記 PostgreSQL 資料庫的管理者密碼該如何重新設定? ...
查看: 3800|回復: 0
go

忘記 PostgreSQL 資料庫的管理者密碼該如何重新設定? [複製鏈接]

Rank: 9Rank: 9Rank: 9

1#
發表於 2010-5-30 00:17 |只看該作者 |倒序瀏覽 |打印
若是因為太久沒有使用而忘記 PostgreSQL 資料庫的管理者 postgres 帳號的密碼, 可以用下列的過程來重新設定:

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

#local all all XXXX

增加一行設定

local all all trust

存檔後重新啟動 postgresql 服務後就可以在主機上免密碼登入
  1. [root@bestlong ~]# psql -U postgres template1
  2. Welcome to psql 8.3.7, the PostgreSQL interactive terminal.

  3. Type:  \copyright for distribution terms
  4.        \h for help with SQL commands
  5.        \? for help with psql commands
  6.        \g or terminate with semicolon to execute query
  7.        \q to quit

  8. template1=# alter user postgres password 'YourNewPassword';
  9. ALTER ROLE
  10. template1=# \q
  11. [root@bestlong ~]#
複製代碼
然後再還原 pg_hba.conf 的設定與重新啟動 postgresql 服務, 以回復到原來的安全性
我是雪龍
http://blog.bestlong.idv.tw
http://www.bestlong.idv.tw
‹ 上一主題|下一主題

Archiver|怕失憶論壇

GMT+8, 2025-5-1 22:29 , Processed in 0.017096 second(s), 14 queries .

Powered by Discuz! X1.5

© 2001-2010 Comsenz Inc.