如何在 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 23:54:34  来源:igfitidea点击:

How do I reset the postgresql 9.2 default user (usually 'postgres') password on mac os x 10.8.2?

macospostgresql

提问by Heath Borders

I just installed PostgreSQL 9.2from enterprisedbonto Mac OS X 10.8.2. I mistyped my postgresuser password, so I can't connect. How do I reset the password?

我刚刚PostgreSQL 9.2Enterprisedb安装到Mac OS X 10.8.2. 我输错了postgres用户密码,所以无法连接。如何重置密码?

回答by Heath Borders

Found directions:

找到方向

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 (\qto 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/