错误使用rakedb:创建postgres - Error using rake db:create with postgres

- 此内容更新于:2016-02-03
主题:

我得到这个错误,我一直试图从sqlite3postgres。这个错误是我的眼中钉。我不能确定如何修复它。无法创建数据库为{“适配器”=>“postgresql”,“池”=>5,“超时”=>5000,“数据库”=>“abc”}不能连接到服务器:没有这样的文件或目录服务器在本地运行,接受连接在Unix域套接字“/var/运行/postgresql/.s.PGSQL.5432”?我想这个问题我可能在我的数据库。yml文件在这里:这是我的git如果你需要看的任何其他文件是什么样子:https://github.com/AceConcept/Todo-App截图当我试图打开程序!http://i.imgur.com/Lxujhyt.jpg到底当我使用rakedb:创建的

原文:

I get this error, I have been trying to switch from sqlite3 to postgres. This error has been a thorn in my side. I am not quite sure how to fix it.

Couldn't create database for {"adapter"=>"postgresql", "pool"=>5, "timeout"=>5000, "database"=>"abc"} 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"?

I think the problem my might be in my database.yml file here it is:

default: &default
  adapter: postgresql
  pool: 5
  timeout: 5000

development:
  <<: *default
  database: abc

# 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: asa

production:
  <<: *default
  database: cba

Here is my git if you need to see what any of the other files look like: https://github.com/AceConcept/Todo-App

A screenshot of what happens when I try to open app !http://i.imgur.com/Lxujhyt.jpg

What exactly happens when I use 'rake db:create'

 bundle exec rake db:create
(in /home/ubuntu/workspace/todo)
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/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `initialize'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `new'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `connect'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/postgresql_adapter.rb:568:in `initialize'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:435:in `new_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:445:in `checkout_new_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `acquire_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:351:in `block in checkout'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:350:in `checkout'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in `retrieve_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_handling.rb:87:in `connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/tasks/postgresql_database_tasks.rb:8:in `connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/tasks/postgresql_database_tasks.rb:17:in `create'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/tasks/database_tasks.rb:88:in `create'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/tasks/database_tasks.rb:102:in `block in create_current'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/tasks/database_tasks.rb:209:in `block in each_current_configuration'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/tasks/database_tasks.rb:208:in `each'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/tasks/database_tasks.rb:208:in `each_current_configuration'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/tasks/database_tasks.rb:101:in `create_current'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/railties/databases.rake:17:in `block (2 levels) in <top (required)>'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/usr/local/rvm/rubies/ruby-2.2.1/bin/rake:33:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "pool"=>5, "timeout"=>5000, "database"=>"abc"}
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/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `initialize'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `new'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `connect'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/postgresql_adapter.rb:568:in `initialize'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:435:in `new_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:445:in `checkout_new_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `acquire_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:351:in `block in checkout'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:350:in `checkout'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in `retrieve_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/connection_handling.rb:87:in `connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/tasks/postgresql_database_tasks.rb:8:in `connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/tasks/postgresql_database_tasks.rb:17:in `create'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/tasks/database_tasks.rb:88:in `create'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/tasks/database_tasks.rb:102:in `block in create_current'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/tasks/database_tasks.rb:209:in `block in each_current_configuration'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/tasks/database_tasks.rb:208:in `each'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/tasks/database_tasks.rb:208:in `each_current_configuration'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/tasks/database_tasks.rb:101:in `create_current'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.1.5/lib/active_record/railties/databases.rake:17:in `block (2 levels) in <top (required)>'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/usr/local/rvm/rubies/ruby-2.2.1/bin/rake:33:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "pool"=>5, "timeout"=>5000, "database"=>"asasasasas"}
网友:当你运行在相同的目录作为您的项目?

(原文:What happens when you run psql in the same directory as your project?)

楼主:我:rake流产!不知道如何构建任务“psql”(见完整的跟踪通过运行的任务,跟踪)

(原文:I get : rake aborted! Don't know how to build task 'psql' (See full trace by running task with --trace))

网友:你有postgres安装吗?如果你在mac上你应该得到postgresapp.com。如果在linux上你应该使用postgresql.org/download/linux/ubuntu或等价的。

(原文:Do you have postgres installed? If you're on a mac you should get the postgresapp.com. If on linux you should use apt-get postgresql.org/download/linux/ubuntu or the equivalent.)

楼主:会工作吗?我使用一个云ide在线cloud9.com

(原文:Will that work? I am using a cloud ide online cloud9.com)

楼主:它不承认apt-get):

(原文:It doesn't recognize apt-get ):)