Capistrano postgresql:致命:用户的对等身份验证失败

时间:2013-07-23 19:55:34

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

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

1)将bundle install添加到Gemfile后,我无法gem 'unicorn'。我发现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网站,我应该得到不同的错误......

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

2 个答案:

答案 0 :(得分:8)

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

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

更多详情here

答案 1 :(得分:1)

您必须先为password or md5 authentication设置Postgres。您通常在pg_hba.conf文件中执行此操作。

只要只允许ident or peer authentication,密码对您没有好处。您只能以与系统用户对应的db用户身份登录。

顺便说一下,用户通常被称为 postgres ,而不是 postgresql ,这不是打字错误,是吗?

您可以尝试使用shell:

sudo su - postgres

然后以postgres db用户身份登录,如果我的假设成立,将自动授权。

这里有更多细节:
PostgreSQL error: Fatal: role "username" does not exist
Run batch file with psql command without password

相关问题