我在创建数据库时遇到了一些麻烦。
我的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