gpt4 book ai didi

ruby-on-rails - 用户身份认证失败

转载 作者:太空宇宙 更新时间:2023-11-04 12:33:36 24 4
gpt4 key购买 nike

我正在尝试使用我不熟悉的 Postgres 数据库设置我的 Rails 应用程序。

我正在使用

  • centos 6
  • postgresql 9.6.2
  • pg_hba.conf 路径 => /var/lib/pgsql/data/pg_hba.conf

我使用 sudo -u postgres psql 登录并创建了一个用户“X”,密码为“password”。以下是详细信息

postgres=# \l

List of databases

Name | Owner | Encoding | Collate | Ctype | Access privileges
--------------+--------------+----------+-------------+-------------+-------------------------------

postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |

template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +

| | | | | postgres=CTc/postgres

template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +

| | | | | postgres=CTc/postgres

trip_staging | X | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =Tc/X +

| | | | | X=CTc/X

(4 rows)

postgres=# \du

                             List of roles

Role name | Attributes | Member of

--------------+------------------------------------------------------------+-----------

X | | {}

postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

当我运行命令时:RAILS_ENV=staging bundle exec rake db:create

我收到以下错误:

FATAL:  Ident authentication failed for user "X"

Couldn't create database for {"database"=>"trip_staging", "adapter"=>"postgresql", "username"=>"X", "password"=>"password", "host"=>"localhost", "port"=>5432, "pool"=>5, "timeout"=>5000}

在此之后,我查找了每个可能的修复方法。我尝试使用以下配置更改 pg_hba.conf:

TYPE  DATABASE USER ADDRESS  METHOD
local all all md5
host all all 0.0.0.0 md5
host all all ::1/128 md5

也尝试过,用 trust 更改 METHOD,然后使用以下命令重新启动 postgresql 服务器:sudo service postgresql-9.6 restart 但同样的错误。

也尝试过,将路径 /var/lib/pgsql/data/pg_hba.conf 的读取权限从 600 更改为 755。为此,我必须使用 sudo su - postgres 作为 postgres super 用户登录,这很奇怪。然后重启postgresql服务器

也尝试过,将路径 /var/lib/pgsql/9.6/data/pg_hba.conf 的方法从 ident 更改为 trust,显然也存在一个版本明智的 pg_hba.conf。然后我重新启动了 PostgreSQL 服务器。

到目前为止似乎没有任何效果。请帮助找出缺少的内容。

最佳答案

在 pg_hba.conf 中,0.0.0.0 的部分需要这样的掩码 0.0.0.0/32,在日志中指出了问题,默认情况下在/var/lib/pgsql/9.6/data/中的 centos pg_log/

关于ruby-on-rails - 用户身份认证失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42612106/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com