【问题标题】:Capistrano postgresql: FATAL: Peer authentication failed for userCapistrano postgresql:致命:用户的对等身份验证失败
【发布时间】:2013-07-23 02:11:50
【问题描述】:

我第一次将应用部署到数字海洋,遇到了两个(可能更多)问题。

1) 将 gem 'unicorn' 添加到 Gemfile 后,我无法 bundle install。我发现kgio与windows不兼容。通过 capistrano 部署时是否必须存在 Gemfile.lock?我将如何解决这个问题?

group :production do
  gem 'pg', '0.14.1'
  gem "nginx"
  gem 'unicorn'
end

2) 我在服务器上的 postgresql 上进行身份验证时遇到问题。

production:
  adapter: postgresql
  encoding: unicode
  database: postgresql
  pool: 5
  username: postgresql
  password: secret

我运行了这些命令(以及其他一些变体):

create user postgresql with password 'secret';
create database postgresql with owner postgresql;

每次我限制部署时,我都会收到此错误:

FATAL: Peer authentication failed for user "postgresql"

我尝试输入一个我知道不存在的无效用户名,一个无效但错误消息始终相同的数据库。根据 postgresql 网站,我应该得到不同的错误......

如果我能得到一些帮助,那就太棒了。谢谢!

【问题讨论】:

    标签: ruby-on-rails postgresql deployment capistrano unicorn


    【解决方案1】:

    您需要指定密码验证的主机。

    production:
      adapter: postgresql
      encoding: unicode
      database: postgresql
      pool: 5
      host: localhost
      username: postgresql
      password: secret
    

    更多详情here

    【讨论】:

      【解决方案2】:

      您必须为 密码md5 设置 Postgres(更安全: scram-sha-256 自 Postgres 11) authentication first - 在 pg_hba.conf 文件中。

      只要只允许ident or peer authentication,就不会提示密码。您只能以系统用户对应的 db 角色登录。

      顺便说一句,数据库角色和操作系统用户通常称为 postgres,而不是 postgresql。我想这不是错字吧?

      在 shell 中尝试:

      sudo -u postgres -i
      

      然后以postgres db 角色登录并进行对等身份验证。

      见:

      【讨论】:

        猜你喜欢
        • 2013-02-24
        • 2018-10-09
        • 2016-03-01
        • 2015-06-18
        • 2013-06-30
        • 2020-11-30
        • 2012-04-16
        • 2021-10-21
        • 2014-05-23
        相关资源
        最近更新 更多