1

我跑rake test並得到了以下錯誤:耙測試失敗 - RunTimeError

/Users/username/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.7/lib/active_record/connection_adapters/postgresql_adapter.rb:1213:in `initialize': could not connect to server: Permission denied (PG::Error) 
Is the server running locally and accepting 
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"? 
. 
. 
. (many filenames) 
. 
. 
Errors running test:units! #<PG::Error: could not connect to server: Permission denied 
Is the server running locally and accepting 
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"? 
> 
Errors running test:functionals! #<RuntimeError: Command failed with status (1): [/Users/username/.rvm/rubies/ruby-2.0.0-p0/bin/...]> 

是什麼意思?我該怎麼做才能解決這個問題? 也,它似乎與PostgresSql,但我不使用該數據庫,我相信。 (哪裏可以檢查?)所以它沒有任何意義...

更新:我錯了,有postgresql。 這是我的config/database.yml文件:

test: 
    adapter: postgresql 
    encoding: unicode 
    database: db_test 
    pool: 5 
    username: db 
    password: 

production: 
    adapter: postgresql 
    encoding: unicode 
    database: db_production 
    host: xx.xxx.xxx.xxx 
    pool: 5 
    username: xxxxx 
    password: xxxxxxx 

這裏從我的Gemfile的數據:

#Running a Postgres Database 
gem 'pg' 

#And using redis for KVS 
gem 'redis' 

#Behind a Thin Server 
gem 'thin' 

我現在的工作我的本地機器上,這是一個項目,我拉。也許我的本地機器有一個特定的數據庫(我使用mysql我相信),但應用程序期待另一個?

更新: 我的本地計算機(Mac OS)確實有postgresql,我可以使用which psql找到它。如何配置數據庫並使其全部正常工作?

+1

關於你的config/database.yml的信息可能很重要,你應該發佈它。之前刪除它的密碼! – pierallard

+1

你在'Gemfile'中指定了哪個數據庫? –

+0

謝謝@ForgetTheNorm和@ Alex Lynham,我剛剛發佈了其他信息 –

回答

1

這可能是由於以下幾個問題:

  • 的dabatase db_test不存在
  • 用戶db不存在
  • 用戶db有密碼
  • host絕被指定爲

換句話說,取ti我在test部分配置您的database.yml,然後運行rake db:test:prepare來初始化您的數據庫。

所有DB從耙可獲取命令:rake -T | grep db

3

,如果你沒有在本地機器PSQL。只需繼續使用mysql本身。

在你的Gemfile刪除寶石 'PG',給寶石 'mysql2'

給 捆綁安裝 耙分貝:創建 耙分貝:遷移

之前,讓你的MySQL數據庫密碼在database.yml文件中。