致命:对用户“ rails”的对等身份验证失败 [英] FATAL: Peer authentication failed for user "rails"

查看:106
本文介绍了致命:对用户“ rails”的对等身份验证失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在DigitalOcean服务器上使用postgresql运行rake db:create

I'm trying to run rake db:create with postgresql on a DigitalOcean server.

但是,它返回错误对用户 rails的对等身份验证失败,指的是 config / database.yml 登录存储

However, it's returning the error Peer authentication failed for user "rails", referring to config/database.yml where the credentials to log in are stored

奇怪的是,这些是我通过SSH登录服务器时以纯文本形式显示给我的确切凭据。我已经尝试了<%= ENV ['APP_DATABASE_PASSWORD']%> 和以纯文本形式显示给我的密码,并且发生了同样的事情。

What's strange is that these are the exact credentials displayed to me in plain text when I log into the server through SSH. I've tried both <%= ENV['APP_DATABASE_PASSWORD'] %> and the password displayed to me in plain text and the same thing happens.

该环境处于生产环境中,我必须手动执行该操作,因为该应用程序在启动时仍处于开发阶段,并迫使其在 config / environments.rb中进行更改无法正常工作。

The environment is in production, which I have to enforce manually because the app is in development on startup and forcing it to change in config/environments.rb isn't working.

如果我不得不猜测,我可能会说环境正在发生一些有趣的事情,因为DigitalOcean将继续为缓存提供服务直到重新启动服务器为止的站点版本,并且就其而言,它可能仍认为它正在开发中。但是直到我弄清楚如何在启动时将其强制投入生产之前,我一直处于困境。

If I had to guess I might say that something funny is happening with the environment, because DigitalOcean will continue to serve a cached version of the site until the server is restarted and it might still think it's in development as far as it's concerned. But I'm in kind of a catch-22 until I figure out how to force it into production on startup.

这个问题是我与postgres发生了很多麻烦,并尝试在后端建立数据库,所以我需要完成一些事情。

This question is what I've arrived at after a lot of tribulation with postgres and trying to set up a database on the backend, so I need to be walked through a couple things.

非常感谢。

推荐答案

问题出在您的 pg_hba.conf 文件中。您可以在 /etc/postgresql/9.3/main/pg_hba.conf 中找到该文件。这里9.3是postgres版本,您可以使用postgres版本进行更改。 此处

The problem is with your pg_hba.conf file. Which you can find in /etc/postgresql/9.3/main/pg_hba.conf. Here 9.3 is postgres version, you can change with your postgres version. More detail about authentication is here.

您有类似以下代码:

# TYPE  DATABASE        USER    ADDRESS             METHOD

# "local" is for Unix domain socket connections only
local    all             all                        peer

您可以将其更改为 md5 trust

# TYPE  DATABASE        USER    ADDRESS             METHOD

# "local" is for Unix domain socket connections only
local    all             all                        trust

它将解决您的问题。

注意:要编辑 pg_hba.conf 文件,您应该对服务器具有sudo权限

Note : To edit pg_hba.conf file you should have sudo permission on server.

这篇关于致命:对用户“ rails”的对等身份验证失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆