我已经在我的Ubuntu karma box上安装了PostgreSQL和pgAdminIII。

我能够成功地使用pgAdminIII(即连接/登录),但是当我尝试在命令行(使用psql)上使用相同的用户名/pwd登录到服务器时,我得到错误:

psql: FATAL:  Ident authentication failed for user "postgres"

现在有人知道如何解决这个问题吗?


当前回答

我发现我必须安装一个身份服务器,在113端口上监听。

sudo apt-get install pidentd
sudo service postgresql restart

然后身份就起作用了。

其他回答

我在GCP SQL中通过terraform提供了用户名和密码,问题是密码没有通过terraform正确设置,所以虽然不是一个适当的修复,但只是为了找出确切的原因。

我从GCP控制台更改了用户的密码,这是有效的。

如果你做了所有这些,它仍然不工作,检查该用户的到期:

Postgres密码认证失败

在Ubuntu 12.04中为Rails开发设置PostgreSQL之后,我也遇到了同样的问题

我尝试了其他答案,但我所要做的就是:“config/database.yml”

development:
  adapter: postgresql
  encoding: unicode
  database: (appname)_development
  pool: 5
  username: (username you granted appname database priviledges to)
  password:

关于PostgreSQL安装的配置问题:

在下面提到的conf文件中配置# TYPE数据库用户地址方法部分

查找并编辑/var/lib/pgsql/10/data/pg_hba.conf或根据您的文件位置更新方法(md5)。如果你的配置中不存在,更新文件中的条目,如下所示:

# TYPE  DATABASE        USER            ADDRESS                 METHOD
# "local" is for Unix domain socket connections only
local   all             all                                     trust
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
host    all             all             0.0.0.0/0            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5

在下面提到的conf文件中配置连接和验证部分

查找并编辑/var/lib/pgsql/10/data/postgresql.conf或根据您的文件位置 更新监听地址和端口

listen_addresses = '*' // # what IP address(es) to listen on;
                                    # comma-separated list of addresses;
                                    # defaults to 'localhost'; use '*' for all
port = 5432 // Set port as 5432

重新启动PostgreSQL:

sudo systemctl restart postgresql-10 # Update service name based on your installation

这招对我很管用: http://tecadmin.net/fatal-ident-authentication-failed-for-user-postgres/#

local   all             postgres                                trust
local   all             myapp_usr                               trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
#host    all             all             ::1/128                 trust