【发布时间】:2014-02-04 22:46:35
【问题描述】:
我无法将使用 SQLite3 的现有应用程序更改为 postgreSQL。我正在按照本教程将 SQLite3 转换为 postgreSQL 并将其部署到 heroku:https://devcenter.heroku.com/articles/sqlite3#running-rails-on-postgres。
我删除了 gem 'sqlite3' 并替换为 gem 'pg'。 修改 config/database.yml 后,我运行迁移。
$rake db:create 和 $rake db:migrate 导致此错误:
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
生产中使用的Gemfile:
gem 'rails_12factor'
gem 'thin'
gem 'pg'
以下是我使用本地服务器运行时遇到的错误:
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:825:in `initialize': could not connect to server: No such file or directory (PG::ConnectionBad)
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
【问题讨论】:
-
阅读错误信息。你检查了它告诉你检查的东西吗?您是否搜索过错误消息?我敢打赌你可能也在 Mac 上,在这种情况下,将“OS X”添加到该搜索中,因为对于 PostgreSQL + Rails 的 Mac 用户来说,这是一个常见的问题。很难提供更多帮助,因为您没有提供 PostgreSQL 版本或安装 PostgreSQL 的方式,或您的操作系统和版本。
标签: ruby-on-rails postgresql heroku