0

postgres db を使用して新しい Rails アプリを作成しようとすると、rake コマンドを完了できません。

これが私がやったことです。

sayth@sayth-TravelMate-5740G:~$ sudo -u postgres psql postgres
[sudo] password for sayth: 
psql (9.2.4)
Type "help" for help.

postgres=# create role sayth login createdb;
ERROR:  role "sayth" already exists

postgres=# DROP user sayth;
DROP ROLE
postgres=# create role sayth login createdb;
CREATE ROLE
postgres=# initdb -D /usr/local/pgsql/data
postgres-# \q
sayth@sayth-TravelMate-5740G:~$ 

Railsアプリを作成しました

rails new testapp2 -d postgres

Railscastを見て、なぜうまくいかなかったのかを理解したhttp://railscasts.com/episodes/342-migrating-to-postgresql

だから私は config/database.yml を編集しました

development:
  adapter: postgresql
  encoding: unicode
  database: testapp2_development
  pool: 5
  username: sayth
  password:

test:
  adapter: postgresql
  encoding: unicode
  database: testapp2_test
  pool: 5
  username: sayth
  password:

しかし、それでもレーキは私のデータベースを作成しません。

sayth@sayth-TravelMate-5740G:~/testapp2$ rake db:create:all
FATAL:  Peer authentication failed for user "testapp2"
...
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "database"=>"testapp2_production", "pool"=>5, "username"=>"testapp2", "password"=>nil}

私はたくさん読んだようで、見つけたものは何でも試しましたが、何をすべきかわかりません.

このコマンドも失敗します。

sayth@sayth-TravelMate-5740G:~/testapp2/config$ psql -U postgres
psql: FATAL:  Peer authentication failed for user "postgres"
4

1 に答える 1

1

エラーは実稼働データベースの作成時にのみ発生します。ここでは、間違ったユーザー、'sayth' ではなく 'testapp2' を指定しています。

于 2013-08-18T03:14:52.643 に答える