Postgres數據庫忘記密碼,三個步驟解決(windows)

一、修改data目錄下的 pg_hba.conf 文件

將以下這行

host    all             all             127.0.0.1/32            md5

改爲如下:

host    all             all             127.0.0.1/32            trust

 

二、運行cmd,進入postgres安裝路徑的bin目錄,運行如下命令:

psql -U postgres

 

postgres=# alter user postgres with password '你要設置的密碼';

 

postgres=# \q

 

三、修改data目錄下的 pg_hba.conf 文件

將以下這行

host    all             all             127.0.0.1/32            trust

改爲如下:

host    all             all             127.0.0.1/32            md5

重新啓動postgres
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章