我使用的是MacOSX Lion,ruby 1.9.2,Rails 3.1.2和postgres 9.0.4
我做了一个rake db:在我的应用程序上使用postgres进行迁移.它访问被拒绝错误失败.
** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Invoke db:load_config (first_time) ** Invoke rails_env (first_time) ** Execute rails_env ** Execute db:load_config ** Execute 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"?
我检查了服务器是否正在运行,它运行正常.我可以使用成功连接到我的数据库
psql -Umyuser myapp_development psql -Umyuser myapp_test
在创建一个新的PG用户时,它从来没有要求我输入密码,所以我没有给这个用户myuser的密码.
这是我的database.yml文件.
development: adapter: postgresql encoding: utf8 database: myapp_development username: pgguy test: adapter: postgresql encoding: utf8 database: myapp_test username: pgguy production: adapter: postgresql encoding: utf8 database: myapp_production
我应该怎么做,从我的rails应用程序连接到它?
解决方法
添加主机到我的database.yml文件解决了这个.
development: adapter: postgresql encoding: utf8 database: myapp_development username: myuser host: localhost test: adapter: postgresql encoding: utf8 database: myapp_test username: myuser host: localhost production: adapter: postgresql encoding: utf8 database: myapp_production
我提到这个线程的解决方案:Repairing Postgresql after upgrading to OSX 10.7 Lion