如何在 mac os x 10.8.2 上重置 postgresql 9.2 默认用户(通常是“postgres”)密码?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13921380/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I reset the postgresql 9.2 default user (usually 'postgres') password on mac os x 10.8.2?
提问by Heath Borders
I just installed PostgreSQL 9.2
from enterprisedbonto Mac OS X 10.8.2
. I mistyped my postgres
user password, so I can't connect. How do I reset the password?
我刚刚PostgreSQL 9.2
从Enterprisedb安装到Mac OS X 10.8.2
. 我输错了postgres
用户密码,所以无法连接。如何重置密码?
回答by Heath Borders
找到方向:
sudo su postgres
modify /Library/PostgreSQL/9.2/data/pg_hba.conf
修改/Library/PostgreSQL/9.2/data/pg_hba.conf
-local all all md5
+local all all trust
restart postgres
重启 postgres
/Library/PostgreSQL/9.2/bin/pg_ctl restart -D /Library/PostgreSQL/9.2/data/
Connect to postgres:
连接到 postgres:
psql
Inside psql (\q
to quit):
在 psql 中(\q
退出):
ALTER USER postgres WITH ENCRYPTED PASSWORD 'password';
modify pg_hba.conf back
修改 pg_hba.conf 回来
+local all all md5
-local all all trust
restart postgres
重启 postgres
/Library/PostgreSQL/9.2/bin/pg_ctl restart -D /Library/PostgreSQL/9.2/data/