【问题标题】:PostgreSQL rake db:migrate errorPostgreSQL rake db:迁移错误
【发布时间】:2012-09-17 21:19:38
【问题描述】:

刚刚用

开始了一个新应用
rails <appname> new -d postgresql

我最近安装了 Postgres,这是我第一次尝试将它与应用程序一起使用。我生成了一大堆模型,然后运行 ​​rake db:migrate 并得到以下错误:

rake aborted!
could not connect to server: Permission denied
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

这是否意味着我错误地安装了 Postgres?知道我应该解决什么吗?或者问题是否与尝试一次迁移多个模型有关?对不起,如果这是一个愚蠢的问题。我是 Rails 和 postgres 的新手。

----- 我的数据库.YML -----

development:
  adapter: postgresql
  encoding: unicode
  database: <appname>_development
  pool: 5
  username: <appname>
  password:

  # Connect on a TCP socket. Omitted by default since the client uses a
  # domain socket that doesn't need configuration. Windows does not have
  # domain sockets, so uncomment these lines.
  #host: localhost
  #port: 5432

  # Schema search path. The server defaults to $user,public
  #schema_search_path: myapp,sharedapp,public

  # Minimum log levels, in increasing order:
  #   debug5, debug4, debug3, debug2, debug1,
  #   log, notice, warning, error, fatal, and panic
  # The server defaults to notice.
  #min_messages: warning

# 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:
  adapter: postgresql
  encoding: unicode
  database: <appname>_test
  pool: 5
  username: <appname>
  password:

production:
  adapter: postgresql
  encoding: unicode
  database: <appname>_production
  pool: 5
  username: <appname>
  password:

--- 执行initdb /usr/local/var/postgres -E utf8 ---

得到以下信息:

initdb /usr/local/var/postgres -E utf8
The files belonging to this database system will be owned by user "sashafklein".
This user must also own the server process.

The database cluster will be initialized with locale en_US.UTF-8.
The default text search configuration will be set to "english".

initdb: directory "/usr/local/var/postgres" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/usr/local/var/postgres" or run initdb
with an argument other than "/usr/local/var/postgres".

【问题讨论】:

    标签: ruby-on-rails postgresql rake


    【解决方案1】:

    您是否创建了 config/database.yml?

    这基本上保存了 Postgres 的连接信息

    看起来像这样

    development:
      adapter: postgresql
      encoding: unicode
      database: <appname>_development
      pool: 5
      username: <username>
      password: <password>
    

    【讨论】:

    • 是的。是在我做 Rails New 时自动创建的。我会在上面贴出来。
    • 尝试安装 Pgadmin 或运行它看看它是否真的在运行 /etc/init.d/postgresql status
    • 试过 initdb /usr/local/var/postgres -E utf8,因为我不知道你运行上面的意思是什么,我想重新初始化它可能会让它运行或告诉如果不是我。上面发布了终端响应。
    • 射击。我还尝试了“pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start”来启动服务器,但它没有工作。 (我是从安装说明中得到的)。
    • 嗯,这就是我管理 postgres 的能力的终结……你是如何安装它/什么操作系统的?
    猜你喜欢
    • 1970-01-01
    • 2013-09-07
    • 1970-01-01
    • 1970-01-01
    • 2013-08-05
    • 1970-01-01
    • 2016-01-19
    • 2011-04-29
    • 2012-06-16
    相关资源
    最近更新 更多