问题描述
我正在尝试为Mac(10.7 Lion)上的Rails应用程序在本地安装Postgres安装程序。
I am trying to get postgres setup locally for a rails app on my mac (10.7 Lion).
我安装了并启动它,现在我在状态栏中有一个大象告诉我postgres正在运行。
I installed postgresapp and launched it, I now have an elephant in my status bar telling me that postgres is running.
我可以了解它创建者:
psql -h localhost
但是当我简单地运行 psql
时,会出现此错误:
But when I simply run psql
I get this error:
我说的是:
PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
在〜/ .bashrc
并打开一个新终端。但是没有骰子。
In ~/.bashrc
and opened a new terminal. But no dice.
当我运行哪个psql
时,我得到 / usr / bin / psql
不太确定该怎么做。.我对于UNIX系统还是很陌生。我应该将 / usr / bin / psql
链接到 /Applications/Postgres.app/Contents/MacOS/bin/psql
?
Not really sure what to do.. I am still pretty new to unix systems. Should I symlink /usr/bin/psql
to /Applications/Postgres.app/Contents/MacOS/bin/psql
?
推荐答案
在运行Mountain Lion的新MacBook Pro上,我遇到了类似的问题。我下载了,当我启动导轨时,出现以下错误:
I had a similar issue on my new MacBook Pro running Mountain Lion. I downloaded the PostgresApp and when I fired up rails I received the following error:
`initialize': could not connect to server: No such file or directory (PG::Error)
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
要解决此问题,我必须在数据库中明确定义主机和端口.yml
文件,如下所示:
To fix this I had to explicitly define the host and port in my database.yml
file like so:
development:
adapter: postgresql
encoding: unicode
database: my_app_development
pool: 5
username: tony
password: stark
host: localhost
port: 5432
这篇关于尝试在OSX上设置Postgres的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!