【问题标题】:PostgreSQL rake db:create Error in local environmentPostgreSQL rake db:在本地环境中创建错误
【发布时间】:2013-04-18 14:03:45
【问题描述】:

每当我在本地环境中使用 postgreSQL 进行 Rails 应用程序开发时,我都会继续遇到问题。

我在 Mac OS X 10.7 上运行。我知道这个版本预装了 Postgres 版本。

我最初使用the brew method 安装了 Postgres,并且至少有几次成功。我知道用户身份验证问题。

在输入psql --versionwhich psql 以确定正在使用哪个安装时,我必须先调整我的.bash_profile 以使用export PATH=/usr/local/bin:$PATH 反映适当的路径。

我现在遇到的问题是,我的机器在没有正确关闭 PostgreSQL 的情况下已经重新启动,而 Google 几个小时都没有解决这个问题。反过来,当我尝试在新应用程序上执行 rake db:create 时,我收到以下错误,我收到以下错误:

Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "database"=>"app_development", "pool"=>5, "username"=>"tomgeoco", "password"=>nil} could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

我的 config/database.yml 看起来像:

    development:
      adapter: postgresql
      encoding: unicode
      database: app_development
      pool: 5
      username: tomgeoco
      password: 

    test:
      adapter: postgresql
      encoding: unicode
      database: app_development
      pool: 5
      username: tomgeoco
      password: 

    production:
      adapter: postgresql
      encoding: unicode
      database: app_development
      pool: 5
      username: tomgeoco
      password: 

当我使用 ps auxwww | grep postgre 检查 Postgres 服务器的状态时,我得到以下信息:

tomgeoco 12596 0.0 0.0 2434892 408 s000 R+ 11:54AM 0:00.00 grep postgres

那么在这种情况下会出现什么问题呢?

【问题讨论】:

  • password"=>nil || 你用有效密码试过了吗?

标签: ruby-on-rails rails-postgresql


【解决方案1】:

这个问题不是关于rails,而是关于postgres。我最近在 django 项目中遇到了完全相同的问题。

根据您的 ps 输出,postgres 目前无法正常工作。

首先你必须检查日志,我的是/usr/local/var/postgres/server.log。它会让您了解 postgre 启动时出了什么问题。

通过修复 .bash_profile 中的 PATH 变量解决了我的问题。

尝试手动启动您的 postgre 服务器检查其所有输出。如果一切正常但在系统重新启动时损坏,请检查您的 launchctl 守护程序以找出使用了哪个配置文件。这也可能是个问题。

Here 你可以找到清楚安装 brew 版本的 postgres 的良好说明。 here 正在修改 postgres 默认设置,这也可能有用。

【讨论】:

    猜你喜欢
    • 2011-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-22
    • 2016-05-09
    • 1970-01-01
    • 2019-01-10
    • 2013-03-12
    相关资源
    最近更新 更多