2016-06-14 13 views
0

私はPostgreSQLを使用して本番モードでRailsアプリケーションのデータベースを作成しようとしています。Railsアプリケーション用の本番データベースを作成できません

私はコマンドを実行すると:

$ RAILS_ENV=production rake db:create 

を私は次のエラーを取得する:

FATAL: database "postgres" does not exist 
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "host"=>"localhost", "database"=>"provenword", "pool"=>5, "username"=>"postgres", "password"=>"password"} 

私は私が持っている高齢のRailsアプリケーション用のデータベースを作成することができます。しかし、このエラーのみが私にこのエラーを与えます。どのように私はデータベースを作成し、アプリケーションを実行することができますこれを動作させることができますか?

宝石ファイル:

.. 
    gem 'pg' 
.. 

Railsのバージョン - 4.2.6

データベースYML

# 
default: &default 
    adapter: sqlite3 
    pool: 5 
    timeout: 5000 

# default: &default 
# user: postgres 
# password: password 
# pool: 5 
# timeout: 5000 



development: 
    <<: *default 
    database: db/development.sqlite3 

# 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: 
    <<: *default 
    database: db/test.sqlite3 

production: 
    adapter: postgresql 
    encoding: unicode 
    host: localhost 
    database: provenword 
    pool: 5 
    username: postgres 
    password: password 

PostgreSQLは私のサーバーにインストールされています。

+0

は、サーバーにインストールさpostgresのですか? 'which psql'はpostgresqlの検索に役立ちます。 – Emu

+0

私はpostgresとそのための有効なgemを使いたいと思っていました。あなたはそれを本番環境にインストールしていないかもしれません。 – PatNowak

+1

私は 'postgresql'はあなたのケース' postgres'にあるユーザ名と同じ名前のデータベースが存在することを期待しています。最初に 'postgres'という名前のデータベースをセットアップし、' RAILS_ENV = production rake db:create'を実行することができます。 – Dharam

答えて

0

@Dharamに感謝します。

それだけでなく、私のために仕事です:

I beleive postgresql expects a database with the same name as the user name, in your case postgres , be present. First setup a database with the name postgres then you can run RAILS_ENV=production rake db:create

関連する問題