postgres 8.3 中的密码不起作用

发布于 2024-10-16 19:30:59 字数 156 浏览 3 评论 0原文

我已经安装了postgres 8.3,我在安装时输入了test作为密码...我的问题是每次我尝试访问本地数据库...每次我输入密码...它说数据库连接失败.. .我尝试通过命令行更改密码,但它不起作用...甚至尝试更改配置文件...它不起作用...我有什么方法可以使数据库工作吗?谢谢你的回复...

i have installed postgres 8.3, i entered test as the password while the installation...my problem is that each time i try to access the local database...each time i enter the password...it say database connecting failed...i have tried to change the password via command line but it does not work...even tried to change the configuration file...it does not work...is there any way out for me to make the database work? thanks for your reply...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心碎无痕… 2024-10-23 19:30:59

人们通常无法使用密码连接到 postgres,因为它默认配置为对本地连接使用 ident 身份验证。尝试切换到 postgres 系统帐户并使用该用户名进行连接。如果您在没有密码的情况下进入,则您已配置为身份。您还可以检查 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 用户是超级用户,如果您更改该身份验证机制,您可能无法进入。

Often people cannot connect to postgres with a password because it is configured by default to use ident authentication for local connections. Try switching to the postgres system account and connecting with that username. If you get in without a password you're configured for ident. You can also check the authentication methods in pg_hba.conf.

If you want to switch to using passwords for local connections, you can modify the setting in pg_hba.conf. At the bottom of the file there's a section like this:

# 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

You can see on the second "local" line I have changed my setting to use md5 authentication instead of ident sameuser. That allows me to log in as any database user from my system account by using the correct password. If you make the same change and restart postgres that might solve your problem.

Be careful not to change the first "local" line. The postgres user is the super user and if you change that authentication mechanism you may not be able to get in.

无尽的现实 2024-10-23 19:30:59

除了有关编辑 pg_hba.conf 的评论之外,我还必须为自己设置一个密码,就像在这个线程

http://ubuntuforums.org/showthread.php?t=388632

使用

ALTER USER postgres WITH ENCRYPTED PASSWORD 'yourhardtoguesspassword';

In addition to the comment about editing pg_hba.conf, I also had to set a password for myself like in this thread

http://ubuntuforums.org/showthread.php?t=388632

using

ALTER USER postgres WITH ENCRYPTED PASSWORD 'yourhardtoguesspassword';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文