postgresql 使 database.yml 文件在 OSX 上的 Rails 中工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9851349/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Making the database.yml file work in Rails on OSX
提问by Jay
I understand that using postgres on osx is a little difficult because it has its own version running, and so in order to psql to it you need to supply the host name like so
我知道在 osx 上使用 postgres 有点困难,因为它有自己的版本在运行,所以为了 psql,你需要像这样提供主机名
psql -h localhost mydatabasename -U me
psql -h localhost mydatabasename -U me
However how do you do this for your database.yml file for all the rail loveliness.
但是,您如何为所有铁路可爱的 database.yml 文件执行此操作。
If you try to connect with
如果您尝试与
development:
adapter: postgresql
username: me
database: mydatabasename
you receive the classic
你收到经典
Couldn't create database for {"adapter"=>"postgresql", "username"=>"me", "database"=>"mydatabasename"}
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Any ideas on how to supply the information or config osx not to suck so much?!
关于如何提供信息或配置 osx 不那么糟糕的任何想法?!
回答by Milen A. Radev
If you're able to connect to Postgres on localhost with psql
, then just add:
如果您能够使用 连接到本地主机上的 Postgres psql
,则只需添加:
host: localhost
to the database.yml
到 database.yml
回答by Dmitry Rybakov
My working configuration is as follows:
我的工作配置如下:
development:
adapter: postgresql
database: database_name
host: localhost
username: user_name
pool: 5
timeout: 5000
So I suppose you need to add host: localhost.
所以我想你需要添加主机:本地主机。
回答by Piyush R Gupta
development:
adapter: postgresql
encoding: utf8
database: name
username: hading
password: my_db_password
host: localhost # not mandatory
pool: 5 # not mandatory
timeout: 5000 # not mandatory