PostgreSQL“没有pg_hba.conf条目”错误 [英] Postgresql "no pg_hba.conf entry" error

查看:549
本文介绍了PostgreSQL“没有pg_hba.conf条目”错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Rails项目(我要加入的项目)建立本地Postgresql数据库,并执行以下操作:

I'm setting up my local postgresql database for a rails project (that I'm joining), and have done the following:


  • 已安装postgres

  • 添加/捆绑了 pg gem

  • 创建了一个名为 foobar的数据库用户

  • 创建了一个名为 foobar_development的数据库

  • Installed postgres
  • Added/bundled 'pg' gem
  • Created a db user named "foobar"
  • Created a db named "foobar_development"

Rails应用程序附带了一个rake db:migrate任务。运行此任务时,收到以下错误输出:

The rails app comes with a rake db:migrate task. When I run this task, I get the following error output:

FATAL:  no pg_hba.conf entry for host "::1", user "foobar", database "foobar_development", SSL off

我找到了pg_hba.conf文件在以下位置:

I found a pg_hba.conf file in the following location:

/ usr / local / var / postgres

/usr/local/var/postgres

以下是pg_hba的相关部分.conf文件:

Here's the relevant part of the pg_hba.conf file:

# TYPE  DATABASE        USER            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
# Allow replication connections from localhost, by a user with the
# replication privilege.

#local   replication     jimmyli                                trust
#host    replication     jimmyli        127.0.0.1/32            trust
#host    replication     jimmyli        ::1/128                 trust

我正在使用Mac附带的postgres(版本9.2.4),尽管我担心我可能已经安装了它的另一个版本其他地方(应该将其删除-无论如何我都可以检查一下?)。我还使用Postgres.app运行psql。 ( http://postgresapp.com/ )。

I am using the postgres that came with my Mac (version 9.2.4), although I'm worried I might have installed another version of it somewhere else (and ought to remove it - anyway I can check this?). I am also using Postgres.app to run psql. (http://postgresapp.com/).

我认为我的pg_hba.conf文件应该可以正常工作(因为我为所有用户提供了访问所有数据库的权限),所以我想知道那里是否还有另一个pg_hba.conf文件,并且我正在查看错误的一个/一个没有被使用。

I think my pg_hba.conf file ought to work correctly (since I'm giving all users access to all dbs), so I wonder if there's another pg_hba.conf file out there, and that I'm looking at the wrong one/one that's not being used. How can I test this hypothesis?

推荐答案

知道了!看起来我在查看错误/不相关的pg_hba.conf文件。为了找到合适的文件,我使用psql登录数据库并运行 SHOW hba_file

Got it! Looks like I was looking at the wrong/irrelevant pg_hba.conf file. To find the right one, I logged into the db with psql and ran "SHOW hba_file"

这给了我相关文件的路径,在我的情况下是:

This gave me the path to the relevant file, which in my case was:

/Library/PostgreSQL/9.1/data

/Library/PostgreSQL/9.1/data

然后我将正确的行(请参阅我的问题)添加到这个问题,一切正常!!

I then added the right lines (see my question) to this question, and everything worked!.

这篇关于PostgreSQL“没有pg_hba.conf条目”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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