Rails无法登录到postgresql - PG :: Error - password - 正确的信息 [英] Rails can't login to postgresql - PG::Error - password - Correct info
问题描述
这是我的database.yml文件的样子(显然有测试和生产的相关条目)
开发:
adapter:postgresql
encoding:unicode
database:dbname_dev
pool:5
username:username
password:tehpass
在终端中,我可以成功运行以下操作并登录数据库:
psql -U username dbname_dev
rails项目并运行
rails g控制器ComingSoon索引
当我访问localhost时,我收到以下消息:3000 / coming_soon(尽管双重和三重检查登录凭据)
fe_sendauth:没有提供密码
Database.yml:
连接:& connection
适配器:postgresql
编码:unicode
池:5
用户名:username
password:tehpass
development:
<< ;: * connection
database:dbname_development
test:
< ;:* connection
database:dbname_test
production:
<< ;: * connection
database:dbname_production
如果这对您不起作用,那么在安装过程中可能会出错。
访问此 blog ,希望这可能会帮助你。
/ p>
错误个案:
e_sendauth:未提供密码
fe_sendauth:未提供密码
发生在股票Ubuntu安装,并且是由于pg_hba.conf的权限默认情况下过于限制。要允许rails连接,只需更改pg_hba.conf底部,如下所示。
#TYPE DATABASE USER CIDR-ADDRESS方法
#local仅用于Unix域套接字连接
local all all trust
#IPv4本地连接:
host all all 127.0.0.1/32 trust
#IPv6本地连接:
host all all :: 1/128 trust
让我知道这是否有帮助?
This is how my database.yml file looks (obviously there are relevant entries for testing and production as well)
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 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)
fe_sendauth: no password supplied
Any ideas why I can log in to these databases via "psql" but Rails cannot?
解决方案Database.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.
# 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?
这篇关于Rails无法登录到postgresql - PG :: Error - password - 正确的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!