【问题标题】:Rake db:create fails to connect to serverRake db:create 无法连接到服务器
【发布时间】:2017-09-15 14:49:11
【问题描述】:

我在创建数据库时遇到了一些问题。

我的 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。

有人想办法解决这个问题吗?

谢谢。

【问题讨论】:

  • 发布您的撰写文件

标签: postgresql docker-compose rake


【解决方案1】:

你的 postgres 服务器可能还没有启动,试试这个

$sudo service postgresql restart

然后去你的rails项目

$rake db:setup
$rake db:seed
$rake db:migrate

【讨论】:

  • 我说我可以用 psql 客户端连接到它。所以这确实意味着 postgresql 服务器正在运行。
  • @YoannPicquenot 你有没有解决这个问题??我现在遇到了同样的问题
猜你喜欢
  • 1970-01-01
  • 2012-05-26
  • 1970-01-01
  • 2020-12-03
  • 1970-01-01
  • 2019-10-08
  • 2020-01-24
  • 1970-01-01
  • 2011-12-29
相关资源
最近更新 更多