2014-03-25 73 views
5

但是,當我轉到本地主機時,我可以使用postgres.app在Mac上使用postgres.app在應用程序內部沒有任何問題地輸入rails s: 3000它給了我這個錯誤:PG :: ConnectionBad FATAL:角色「myapp」不存在

PG::ConnectionBad 
FATAL: role "myapp" does not exist 

我起初以爲問題是database.yml文件,但Heroku的文檔,甚至說有它的方式是:https://devcenter.heroku.com/articles/getting-started-with-rails4

development: 
adapter: postgresql 
encoding: unicode 
database: myapp_development 
pool: 5 
username: myapp 
password: 

這裏是我的完整的日誌。我見過類似的問題,但他們只是模糊地涉及到這一點。

片段:

Started GET "/" for 127.0.0.1 at 2014-03-25 16:48:31 -0600 

PG::ConnectionBad (FATAL: role "myapp" does not exist 
): 
    activerecord (4.0.2) lib/active_record/connection_adapters/postgresql_adapter.rb:831:in `initialize' 
    activerecord (4.0.2) lib/active_record/connection_adapters/postgresql_adapter.rb:831:in `new' 
    activerecord (4.0.2) lib/active_record/connection_adapters/postgresql_adapter.rb:831:in `connect' 
    activerecord (4.0.2) lib/active_record/connection_adapters/postgresql_adapter.rb:548:in `initialize' 
    activerecord (4.0.2) lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new' 
    activerecord (4.0.2) lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection' 
    activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:440:in `new_connection' 
    activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:450:in `checkout_new_connection' 
    activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:421:in `acquire_connection' 
    activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:356:in `block in checkout' 
    /Users/johncurry/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize' 
    activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `checkout' 
    activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection' 
    /Users/johncurry/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize' 
    activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection' 
    activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:546:in 

有什麼建議?

+1

的可能的複製[PG :: ConnectionBad FATAL:角色 「的Myname」 不存在( http://stackoverflow.com/questions/23338356/pgconnectionbad-fatal-role-myname-does-not-exist) – Meekohi

回答

0

您需要在本地機器上創建Postgres用戶。角色是您的用戶名。

12

看來您並沒有爲應用程序創建用戶帳戶。在psql

CREATE USER myapp WITH PASSWORD 'thepassword'; 

您還需要創建一個數據庫,如果你還沒有:

CREATE DATABASE myapp_development OWNER myapp; 
+0

是'所有者'的應用程序的所有者 - 或者只是從字面上'所有者' –

+1

字面上'所有者'。這是一個關鍵字。請參閱「CREATE DATABASE」手冊。 –

+0

感謝您的區別。 –

相關問題