2016-09-07 9 views
0

私は、PostgresデータベースでRails 5.0.0をセットアップしてアプリケーションを構築しています。Rails 5 Postgres SQLパスワードで問題が発生する

私はあらゆるすくいのコマンドを実行しようとすると、私は次のエラーを取得する:

rake aborted! 
PG::ConnectionBad: fe_sendauth: no password supplied} 

私は問題を修正するに無駄にすべてのスタックオーバーフローの上に見てきました。ここで

は私のpg_hba.confファイルである:ここで

# 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  John        trust 
#host replication  John  127.0.0.1/32   trust 
#host replication  John  ::1/128     trust 

は、開発のための私のdatabase.ymlのファイルです:

development: 
<<: *default 
database: in-the-paint_development 

# The specified database role being used to connect to postgres. 
# To create additional roles in postgres see `$ createuser --help`. 
# When left blank, postgres will use the default role. This is 
# the same name as the operating system user that initialized the database. 
# username: in-the-paint 

# The password associated with the postgres role (username). 
# password: 

# 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 

# The TCP port the server listens on. Defaults to 5432. 
# If your server runs on a different port number, change accordingly. 
# 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 
# Defaults to warning. 
#min_messages: notice 

は最後に、私はpostgresのをインストールするには、次のコマンドを使用:

brew install postgres 
mkdir -p $HOME/Library/LaunchAgents 
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents 
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist 

大きな問題は、私は決してPostgresを設定するときにパスワードを入力するように求められていないということです。私のdatabase.ymlで何を提供するか分からない。空白( "")スペースを残しても問題は解決されません。

このコードで修正できること、またはこの問題を解決するために実行できるコマンドがありますか?

+2

。私が思い出したように、あなたが行ったようにPGをインストールしても、あなたのアプリが期待しているデフォルトのpostgresユーザーは作成されません。 – MarsAtomic

+0

パスワードを追加データベースyml –

答えて

0

これは私がしたものです。 1)pgsqlで新しいユーザーを作成し、パスワードを与え、ユーザーと同じ名前のデータベースを作成し、新しいデータベースを作成するためのユーザー権限を与えます。 2)その後、database.ymlのファイルに

development: 
    <<: *default 
    database: appname_development #this will come by default if you specify to pg while creating app 
    username: user 
    password: password 
    pool: 5 
    host: localhost 
はpsqlのセッションを開始し、あなたが持っているもののユーザーを参照しpg_usersテーブルをチェックし
関連する問題