2017-09-15 203 views
0

我有一些麻煩創建我的數據庫。Rake db:create無法連接到服務器

我的postgresql正在運行。

這裏的database.yml中:

development: 
    <<: *default 
    database: name_of_database 
    User: username 
    Password: tototo 

我得到的消息:

Called from /usr/local/bundle/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:240:in `load_dependency' 
could not connect to server: No such file or directory 
    Is the server running locally and accepting 
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? 
/usr/local/bundle/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize' 
/usr/local/bundle/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new' 
[...] 
/usr/local/bundle/bin/rake:17:in `<main>' 
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"name_of_database", "User"=>"username", "Password"=>"tototo"} 
could not connect to server: No such file or directory 
    Is the server running locally and accepting 
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? 
[...] 
/usr/local/bundle/gems/rake-12.0.0/lib/rake/application.rb:77:in `run' 
/usr/local/bundle/gems/rake-12.0.0/exe/rake:27:in `<top (required)>' 
/usr/local/bundle/bin/rake:17:in `load' 
/usr/local/bundle/bin/rake:17:in `<main>' 
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"name_of_database"} 

我創建的用戶給它的每一個權利。

我可以使用ID連接到postgresql與客戶端。 我還有一個成功連接到postgres的項目。

有人有想法解決這個問題嗎?

謝謝。

+0

安置自己撰寫的文件 –

回答

1

你的Postgres服務器可能沒有開始嘗試這種

$sudo service postgresql restart 

然後轉到您的Rails項目

$rake db:setup 
$rake db:seed 
$rake db:migrate 
+0

我說我可以連接到它與PSQL客戶端。所以它確實意味着postgresql服務器正在運行。 –

+0

@YananPicquenot你設法解決這個問題?我現在遇到同樣的問題 – DaudiHell

+0

@DaudiHell是的,我沒有使用耙子。我手動完成了所有步驟。 –