我已经安装了postgres 8.3,我在安装时输入了test作为密码...我的问题是每次我尝试访问本地数据库...每次我输入密码...它说数据库连接失败.. .我试图通过命令行更改密码,但它不起作用......甚至试图更改配置文件......它不起作用......我有什么办法让数据库工作?感谢您的回复...
问问题
2633 次
2 回答
2
人们通常无法使用密码连接到 postgres,因为它默认配置为使用 ident 身份验证进行本地连接。尝试切换到 postgres 系统帐户并使用该用户名连接。如果您在没有密码的情况下进入,则您已配置为 ident。您还可以检查 pg_hba.conf 中的身份验证方法。
如果要切换到使用密码进行本地连接,可以修改 pg_hba.conf 中的设置。在文件的底部有这样的部分:
# DO NOT DISABLE!
# If you change this first entry you will need to make sure that the
# database
# super user can access the database using some other method.
# Noninteractive
# access to all databases is required during automatic maintenance
# (autovacuum, daily cronjob, replication, and similar tasks).
#
# Database administrative login by UNIX sockets
local all postgres ident sameuser
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5 #ident sameuser
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
您可以在第二个“本地”行看到我已将设置更改为使用 md5 身份验证而不是 ident sameuser。这允许我使用正确的密码从我的系统帐户以任何数据库用户身份登录。如果您进行相同的更改并重新启动可能会解决您的问题的 postgres。
注意不要更改第一行“本地”行。postgres 用户是超级用户,如果您更改该身份验证机制,您可能无法进入。
于 2011-02-09T20:50:41.447 回答
0
除了关于编辑 pg_hba.conf 的评论之外,我还必须像在这个线程中一样为自己设置密码
http://ubuntuforums.org/showthread.php?t=388632
使用
ALTER USER postgres WITH ENCRYPTED PASSWORD 'yourhardtoguesspassword';
于 2011-06-17T09:02:41.993 回答