我看过here和here,但仍然无法解决我的问题。 我的设置完全适用于我的正常Linux,但是当我尝试在我的mac postgres上重新创建它时,无法使用rails。在跟踪来自railscasts的these指令后,我到了运行rake的地步:db:create:all
运行rake db:create:all:
$ rake db:create:all --
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
但运行psql工作正常:
$ psql
psql (9.3.1)
Type "help" for help.
crashandburn4=#
检查运行的postgres端口产量:
$ cat /etc/services |grep post
postgresql 5432/udp # PostgreSQL Database
postgresql 5432/tcp # PostgreSQL Database
所以它似乎不是一个不正确的端口,我的database.yml明确说明了端口:
# database.yml
development:
adapter: postgresql
encoding: unicode
database: blog_development
pool: 5
username: myusername
password:
port: 5432
test:
adapter: postgresql
encoding: unicode
database: blog_test
pool: 5
username: myusername
password:
port: 5432
production:
adapter: postgresql
encoding: unicode
database: blog_production
pool: 5
username: myusername
password:
port: 5432
运行netstat看起来也很好(我认为):
$ netstat -a | grep postgre
tcp6 0 0 localhost.postgres *.* LISTEN
tcp4 0 0 localhost.postgresql *.* LISTEN
tcp6 0 0 localhost.postgres *.* LISTEN
这是关于我可以想出的所有尝试和诊断问题的事情,除了打电话给巫师:)任何人都有任何想法吗?
编辑:解决了我的问题(旧的橡皮鸭调试),我想要发帖,以帮助任何其他可怜的灵魂花一小时挖掘并仔细检查配置文件。答案 0 :(得分:1)
配置不正确,这是通过将主机名包含在配置中来修复的(见下文),一个有趣的注意事项是,这只是我正在运行的macbook pro所必需的,并且不会出现在我使用的Linux机器上
development:
adapter: postgresql
encoding: unicode
database: blog_development
pool: 5
username: myusername
password:
host: localhost
port: 5432
test:
adapter: postgresql
encoding: unicode
database: blog_test
pool: 5
username: myusername
password:
host: localhost
port: 5432
production:
adapter: postgresql
encoding: unicode
database: blog_production
pool: 5
username: myusername
password:
host: localhost
port: 5432