2014-09-01 68 views
1

我是新來的rails,當我試圖運行時發生了一些錯誤bundle exec rake test:prepare, 同樣的問題已經被問到Click here,我已經包含了psql輸出。任何人都可以幫忙謝謝。ActiveRecord :: StatementInvalid:PG :: Error:ERROR:必須是數據庫的所有者

我得到了流動錯誤:

rake aborted! 
ActiveRecord::StatementInvalid: PG::Error: ERROR: must be owner of database testp00 
: DROP DATABASE IF EXISTS "testp00" 
/Users/snailwalker/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-4.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `exec' 
/Users/snailwalker/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-4.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `block in execute' 
/Users/snailwalker/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:435:in `block in log' 
/Users/snailwalker/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-(required)>' 
/Users/snailwalker/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-4.0.2/lib/active_record/railties/databases.rake:370:in `block (3 levels) in <top (required)>' 
Tasks: TOP => db:test:load => db:test:purge 
(See full trace by running task with --trace) 

PSQL:

snailwalker=# \l 
            List of databases 
     Name  | Owner | Encoding | Collate | Ctype |  Access privileges  
-------------------+-------------+----------+---------+-------+----------------------------- 
devep00   | snailwalker | UTF8  | C  | UTF-8 | 
myapp_development | snailwalker | UTF8  | C  | UTF-8 | 
myapp_test  | snailwalker | UTF8  | C  | UTF-8 | 
postgres   | snailwalker | UTF8  | C  | UTF-8 | 
snailwalker  | snailwalker | UTF8  | C  | UTF-8 | 
template0   | snailwalker | UTF8  | C  | UTF-8 | =c/snailwalker    + 
        |    |   |   |  | snailwalker=CTc/snailwalker 
template1   | snailwalker | UTF8  | C  | UTF-8 | =c/snailwalker    + 
        |    |   |   |  | snailwalker=CTc/snailwalker 
testp00   | snailwalker | UTF8  | C  | UTF-8 | 
(8 rows) 

databse.yml:

development: 
    adapter: postgresql 
    encoding: unicode 
    database: devep00 
    pool: 5 
    username: taouan 
    password: 

test: 
    adapter: postgresql 
    encoding: unicode 
    database: testp00 
    pool: 5 
    username: taouan 
    password: 
+0

你可以發佈database.yml – RAJ 2014-09-01 17:59:02

+0

嗨剛發佈,謝謝你c – Snailwalker 2014-09-01 18:01:28

+0

哈哈我只是想通了,有一個用戶名。 「taouan」 – Snailwalker 2014-09-01 18:04:29

回答

1

感謝RAJ提醒我檢查database.yml文件,我爲用戶名設置一個值,我忘了它,默認情況下它應該是一個零,所以我刪除用戶名:「taouan」然後r它的工作原理是bundle exec rake test:prepare。替代方法是ALTER DATABASE testp00 OWNER TO "taouan"

+0

在用戶名後面什麼都不用:解決我的問題,起初我沒有用戶名和密碼:並且導致錯誤。 – 2016-09-16 05:00:49

相關問題