1

试图让 postgres 与 Lion 合作。当我运行 rake:db create 我得到:

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"?

关于同一问题有很多 SO 主题,但没有一个解决方案对我有用。这是我尝试过的:

  • 卸载并重新安装 pg gem
  • 安装了 postgres.app(当我连接到本地服务器时,pg 仍然无法工作)
  • 更新了路径文件,使 usr/local/bin 位于 usr/bin 之上
  • 将 var/pgsql_socket 的权限更改为所有人的读/写权限

可能的提示是,当我运行 which psql 时,结果是 usr/bin/psql - 我相信它应该是 usr/local/bin/psql,但是在直接编辑我的路径文件之后,我不知道为什么它没有改变。Homebrew 对我来说也完全正常(那里没有路径问题)。

有任何想法吗?

编辑 - 我的 database.yml 中有什么:

development:
adapter: postgresql
encoding: unicode
database: hubbed_development
pool: 5
username: hubbed
password:
host: localhost

test:
adapter: postgresql
encoding: unicode
database: hubbed_test
pool: 5
username: hubbed
password:

production:
adapter: postgresql
encoding: unicode
database: hubbed_production
pool: 5
username: hubbed
password:

编辑 - 运行 ps aux | grep postgres:

 666   0.0  0.0  2445588    540   ??  Ss    9:42am   0:00.00 postgres: checkpointer process      
 664   0.0  0.1  2445588   3604   ??  S     9:42am   0:00.02 /Applications/Postgres.app/Contents/MacOS/bin/postgres -D /Users/angsmith/Library/Application Support/Postgres/var -p5432
 681   0.0  0.0  2434892    540 s000  S+    9:43am   0:00.00 grep postgres
 670   0.0  0.0  2441868    396   ??  Ss    9:42am   0:00.00 postgres: stats collector process      
 669   0.0  0.0  2445720   1524   ??  Ss    9:42am   0:00.00 postgres: autovacuum launcher process      
 668   0.0  0.0  2445588    488   ??  Ss    9:42am   0:00.00 postgres: wal writer process      
 667   0.0  0.0  2445588    524   ??  Ss    9:42am   0:00.01 postgres: writer process  

编辑 - 在 postgress.app 中看到我的用户名是“postgres”。将我的 database.yml 用户名更新为 postgres 并运行 bundle exec rake db:create:all 后,我现在收到以下错误(与以前不同):

 rake aborted!
 dlopen(/Users/angsmith/.rvm/gems/ruby-1.9.3-p374/gems/pg-0.14.1/lib/pg_ext.bundle, 9): Library not loaded: /usr/local/lib/libpq.5.5.dylib
 Referenced from: /Users/angsmith/.rvm/gems/ruby-1.9.3-p374/gems/pg-0.14.1/lib/pg_ext.bundle
 Reason: image not found - /Users/angsmith/.rvm/gems/ruby-1.9.3-p374/gems/pg-0.14.1/lib/pg_ext.bundle
 /Users/angsmith/.rvm/gems/ruby-1.9.3-p374/gems/pg-0.14.1/lib/pg.rb:4:in `require'
 /Users/angsmith/.rvm/gems/ruby-1.9.3-p374/gems/pg-0.14.1/lib/pg.rb:4:in `<top (required)>'
 /Users/angsmith/.rvm/gems/ruby-1.9.3-p374/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `require'
 /Users/angsmith/.rvm/gems/ruby-1.9.3-p374/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
 /Users/angsmith/.rvm/gems/ruby-1.9.3-p374/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `each'
 /Users/angsmith/.rvm/gems/ruby-1.9.3-p374/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `block in require'
 /Users/angsmith/.rvm/gems/ruby-1.9.3-p374/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `each'
 /Users/angsmith/.rvm/gems/ruby-1.9.3-p374/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `require'
 /Users/angsmith/.rvm/gems/ruby-1.9.3-p374/gems/bundler-1.2.3/lib/bundler.rb:128:in `require'
 /Users/angsmith/hubbedspree/config/application.rb:7:in `<top (required)>'
 /Users/angsmith/hubbedspree/Rakefile:5:in `require'
 /Users/angsmith/hubbedspree/Rakefile:5:in `<top (required)>'
 /Users/angsmith/.rvm/gems/ruby-1.9.3-p374/bin/ruby_noexec_wrapper:14:in `eval'
 /Users/angsmith/.rvm/gems/ruby-1.9.3-p374/bin/ruby_noexec_wrapper:14:in `<main>'
 (See full trace by running task with --trace)
4

2 回答 2

4

在我的情况下,重新安装 pg gem 修复了它。

于 2013-04-15T21:20:52.397 回答
0

的条目development有该host: localhost行,但testproduction配置缺少它。

如果您的 3 个数据库位于同一台服务器上,则它应该包含在所有配置中。

于 2013-02-15T23:05:05.660 回答