LINUX.ORG.RU
ФорумAdmin

Нет коннекта RoR с Postgresql

 ,


1

1

При попытке сделать rake db:create в RoR выдает:

DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead. (called from <top (required)> at /usr/lib/ruby/vendor_ruby/activerecord.rb:2)
[b]FATAL:  Peer authentication failed for user "postgres"[/b]
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/postgresql_adapter.rb:950:in `initialize'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/postgresql_adapter.rb:950:in `new'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/postgresql_adapter.rb:950:in `connect'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/postgresql_adapter.rb:246:in `initialize'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/postgresql_adapter.rb:25:in `new'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/postgresql_adapter.rb:25:in `postgresql_connection'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:229:in `new_connection'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:237:in `checkout_new_connection'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:191:in `block (2 levels) in checkout'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:187:in `loop'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:187:in `block in checkout'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:186:in `checkout'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:94:in `connection'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:317:in `retrieve_connection'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/connection_specification.rb:97:in `retrieve_connection'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in `connection'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/railties/databases.rake:101:in `rescue in create_database'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/railties/databases.rake:45:in `create_database'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/railties/databases.rake:33:in `block (2 levels) in <top (required)>'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/usr/local/bin/rake:23:in `load'
/usr/local/bin/rake:23:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "database"=>"app_test", "pool"=>5, "username"=>"postgres", "password"=>1234}
FATAL:  Peer authentication failed for user "postgres"
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/postgresql_adapter.rb:950:in `initialize'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/postgresql_adapter.rb:950:in `new'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/postgresql_adapter.rb:950:in `connect'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/postgresql_adapter.rb:246:in `initialize'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/postgresql_adapter.rb:25:in `new'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/postgresql_adapter.rb:25:in `postgresql_connection'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:229:in `new_connection'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:237:in `checkout_new_connection'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:191:in `block (2 levels) in checkout'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:187:in `loop'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:187:in `block in checkout'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:186:in `checkout'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:94:in `connection'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:317:in `retrieve_connection'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/connection_specification.rb:97:in `retrieve_connection'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in `connection'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/railties/databases.rake:101:in `rescue in create_database'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/railties/databases.rake:45:in `create_database'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.0.10/lib/active_record/railties/databases.rake:35:in `block (2 levels) in <top (required)>'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/home/anton/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/usr/local/bin/rake:23:in `load'
/usr/local/bin/rake:23:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "database"=>"app_development", "pool"=>5, "username"=>"postgres", "password"=>1234}

Хотя pg_hba.conf :

# TYPE DATABASE USER ADDRESS METHOD

# "local" is for Unix domain socket connections only
local all all ident
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres ident
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5



Последнее исправление: cetjs2 (всего исправлений: 2)

FATAL: Peer authentication failed for user «postgres»

peer - по идентификатору локального пользователя

http://www.postgresql.org/docs/9.1/static/auth-pg-hba-conf.html

Подозреваю, что нужно указать в приложении адрес БД, а не использовать подключение через unix сокет.

«username»=>«postgres»

На всякий случай напомню, что давать приложению права postgres - очень плохая идея.

router ★★★★★
()
Ответ на: комментарий от router

Вот что гласит yml-файл рельсового проекта

# PostgreSQL. Versions 7.4 and 8.x are supported.
#
# Install the pg driver:
#   gem install pg
# On Mac OS X with macports:
#   gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
#   gem install pg
#       Choose the win32 build.
#       Install PostgreSQL and put its /bin directory on your path.
development:
  adapter: postgresql
  encoding: unicode
  database: app_development
  pool: 5
  username: postgres
  password: 1234

  # Connect on a TCP socket. Omitted by default since the client uses a
  # domain socket that doesn't need configuration. Windows does not have
  # domain sockets, so uncomment these lines.
  #host: localhost
  #port: 5432

  # Schema search path. The server defaults to $user,public
  #schema_search_path: myapp,sharedapp,public

  # Minimum log levels, in increasing order:
  #   debug5, debug4, debug3, debug2, debug1,
  #   log, notice, warning, error, fatal, and panic
  # The server defaults to notice.
  #min_messages: warning

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: postgresql
  encoding: unicode
  database: app_test
  pool: 5
  username: postgres
  password: 1234

production:
  adapter: postgresql
  encoding: unicode
  database: app_production
  pool: 5
  username: postgres
  password: 1234
magnuz
() автор топика
Ответ на: комментарий от router

приложение кстати, тестовое поэтому давать права postgres не страшно

magnuz
() автор топика

Раз ты в настройках не указал порт, то используется unix-socket (т.е. local аутентификация). У тебя она настроена в «ident», т.е. вместо проверки пароля проверяется что пользователь системы под которым ты запускаешь свою софтину (наверное это «anton») равен пользователю которым ты идешь в БД («postres»).

Если у тебя тектовое окружение, то можешь просто заменить «ident» на «trust», тогда он будет всех пускать без проверки

maxcom ★★★★★
()
Последнее исправление: maxcom (всего исправлений: 1)
Ответ на: комментарий от maxcom

заменил на траст. рестартнул. не помогает

magnuz
() автор топика

Добавь в database.yml в development:

host: localhost

Поможет или нет не знаю, но указыать это надо.

Alve ★★★★★
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.