Ruby-on-rails Rails 无法登录 postgresql - PG::Error - 密码 - 正确信息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9630177/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Rails can't login to postgresql - PG::Error - password - Correct info
提问by Tyler Willingham
This is how my database.yml file looks (obviously there are relevant entries for testing and production as well)
这就是我的 database.yml 文件的外观(显然也有用于测试和生产的相关条目)
development:
adapter: postgresql
encoding: unicode
database: dbname_dev
pool: 5
username: username
password: tehpass
In terminal I can successfully run the following and log in to the database:
在终端中,我可以成功运行以下命令并登录到数据库:
psql -U username dbname_dev
However after creating this new rails project and running
但是在创建这个新的 rails 项目并运行之后
rails g controller ComingSoon index
I get the following message when I go to localhost:3000/coming_soon (despite double and triple checking the login credentials)
当我转到 localhost:3000/coming_soon 时,我收到以下消息(尽管对登录凭据进行了两次和三次检查)
fe_sendauth: no password supplied
Any ideas why I can log in to these databases via "psql" but Rails cannot?
为什么我可以通过“psql”登录这些数据库但 Rails 不能?
回答by Manish Das
Database.yml:
数据库.yml:
connection: &connection
adapter: postgresql
encoding: unicode
pool: 5
username: username
password: tehpass
development:
<<: *connection
database: dbname_development
test:
<<: *connection
database: dbname_test
production:
<<: *connection
database: dbname_production
If this is not working for you then, there might be something wrong during installation.
如果这对您不起作用,则可能是安装过程中出现问题。
Visit this blog, hope this might help you out.
访问此博客,希望这可以帮助您。
EDIT
编辑
ERROR CASE:
错误案例:
e_sendauth: no password supplied
fe_sendauth: no password supplied
This happens under a stock Ubuntu install, and is due to the permissions in pg_hba.conf being too restrictive by default. To allow rails to connect, simply change the bottom of pg_hba.conf to look like this.
这发生在 Ubuntu 安装时,并且是由于 pg_hba.conf 中的权限默认过于严格。要允许 rails 连接,只需将 pg_hba.conf 的底部更改为如下所示。
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
Let me know if this helps or not?
让我知道这是否有帮助?

