postgresql – 无法访问postgres文件pg_hba.conf

postgresql – 无法访问postgres文件pg_hba.conf,第1张

概述我运行db:create时收到此错误: FATAL: Peer authentication failed for user "wandrr"/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:i 我运行db:create时收到此错误:
FATAL:  Peer authentication Failed for user "wandrr"/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `initialize'/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `new'/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `connect'/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:326:in `initialize'/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new'/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection'/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'/home/jack/.rvm/rubIEs/ruby-1.9.3-p327/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'/home/jack/.rvm/rubIEs/ruby-1.9.3-p327/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'/home/jack/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrIEve_connection'....Edit out 40 more of these warnings.../home/jack/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `eval'/home/jack/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `<main>'Couldn't create database for {"adapter"=>"postgresql","enCoding"=>"unicode","database"=>"wandrr_test","pool"=>5,"username"=>"wandrr","password"=>nil}

所以我发现我必须编辑pg_hba.conf问题是……它无法打开.它一直告诉我,我没有权限使用此文件.那么我如何获得许可?我正在运行ubuntu 12.10和rails 1.9.3以及postgres 9.1

首先记下系统中pg_hba.conf的位置.如果您不知道但可以连接,请使用Pgadmin-III或psql连接到Pg并运行:
SHOW hba_file;

获取pg_hba.conf的位置.它的位置非常标准;在Ubuntu上它将在/etc/postgresql/[major.minor]/main/pg_hba.conf中,例如/etc/postgresql/9.1/main/pg_hba.conf.在大多数其他发行版中,它将直接位于/ var / lib / pgsql /或/ var / lib / postgresql中,无论是直接还是在版本化目录中.

要编辑此文件,您必须首先指定完整路径或将目录更改为其位置.说:

sudo vi /etc/postgresql/9.1/main/pg_hba.conf

如果您更喜欢更友好的文本编辑器:

sudo nano /etc/postgresql/9.1/main/pg_hba.conf

或者用你喜欢的编辑器替换“nano”,比如gedit.

保存更改后,请记住重新加载Postgresql服务以使其生效.在Ubuntu上你想要:

pg_ctlcluster 9.1 main reload
总结

以上是内存溢出为你收集整理的postgresql – 无法访问postgres文件pg_hba.conf全部内容,希望文章能够帮你解决postgresql – 无法访问postgres文件pg_hba.conf所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1181734.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-02
下一篇 2022-06-02

发表评论

登录后才能评论

评论列表(0条)

保存