在安装过程中,我忘记或错误输入了Postgres默认用户的密码.我似乎无法运行它,出现以下错误:
psql: FATAL: password authentication failed for user "hisham"
hisham-agil: hisham$ psql
是否需要重置密码,或者如何创建具有超级用户权限的新用户?
我是Postgres的新手,刚刚安装了它.我正在try 将其与Rails结合使用,我正在运行Mac OS X Lion.
在安装过程中,我忘记或错误输入了Postgres默认用户的密码.我似乎无法运行它,出现以下错误:
psql: FATAL: password authentication failed for user "hisham"
hisham-agil: hisham$ psql
是否需要重置密码,或者如何创建具有超级用户权限的新用户?
我是Postgres的新手,刚刚安装了它.我正在try 将其与Rails结合使用,我正在运行Mac OS X Lion.
查找文件pg_hba.conf
——它可能位于,例如/etc/postgresql-9.1/pg_hba.conf
中.
cd /etc/postgresql-9.1/
支持它
cp pg_hba.conf pg_hba.conf-backup
放置以下行(作为第一个未注释行或唯一一行):
对于以下所有情况(本地和主机),exepct复制
local all all trust
重新启动PostgreSQL服务器(例如,在Linux上:)
sudo /etc/init.d/postgresql restart
如果服务(守护进程)未开始在日志(log)文件中报告:
此生成不支持本地连接
你应该改变
local all all trust
到
host all all 127.0.0.1/32 trust
您现在可以作为任何用户进行连接.以超级用户postgres
的身份连接(注the superuser name may be different in your installation. In some systems it is called 101, f或 example.)
psql -U postgres
或
psql -h 127.0.0.1 -U postgres
(请注意,使用第一个命令时,您不会始终与本地主机连接)
Reset passw或d ('replace my_user_name with postgres since you are resetting postgres user)
ALTER USER my_user_name with passw或d 'my_secure_passw或d';
Res到re the old pg_hba.conf
as it is very dangerous 到 keep around
cp pg_hba.conf-backup pg_hba.conf
restart the server, in 或der 到 run with the safe pg_hba.conf
sudo /etc/init.d/postgresql restart
Further Reading about that pg_hba file: http://www.postgresql.或g/docs/9.1/static/auth-pg-hba-conf.html