2

运行时遇到问题:

rake db:create:all

我目前有:

$ psql --version
psql (PostgreSQL) 9.3.0

$ which psql
/Applications/Postgres.app/Contents/MacOS/bin/psql

并得到:

$ rake db:create:all
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"?
/Users/stephanecedroni/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `initialize'
/Users/stephanecedroni/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `new'
/Users/stephanecedroni/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `connect'
/Users/stephanecedroni/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:324:in `initialize'
/Users/stephanecedroni/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new'
/Users/stephanecedroni/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection'
/Users/stephanecedroni/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
/Users/stephanecedroni/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
.....
.....

尝试卸载并重新安装pggem,但仍然无法正常工作。

首先尝试关注 Ryan Bates 截屏但遇到了一些问题,然后检查了建议设置此路径的 Heroku Postgres:

PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"

4

1 回答 1

2

可能是 rake 正在尝试连接,/var/pgsql_socket/.s.PGSQL.5432但域套接字实际上在其他地方。我的是在/tmp/.s.PGSQL.5432。你可以试试这些:

host: localhost在您的 database.yml 中指定。例如:

development:
  host: localhost
  # other stuff

或者

在实际居住/var/pgsql_socket/的地方创建一个符号链接。.s.PGSQL.5432

mkdir /var/pgsql_socket
ln -s /tmp/.s.PGSQL.5432 /var/pgsql_socket/.s.PGSQL.5432

您可能还必须 chown 和 chmod 链接。我不确定您是否还必须链接 .s.PGSQL.5432.lock 。

第一个选项要容易得多。不确定是否其中一个更好。

于 2013-10-08T11:59:49.283 回答