我正在尝试将postgreSQL配置为我的本地开发数据库。
当我跑
时brew install postgres
我收到以下错误:
postgresql-9.3.5 already installed
在我的Gemfile中,我在宝石列表中有pg。
当我跑步时
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 "/tmp/.s.PGSQL.5432"?
我的database.yml如下所示:
development:
adapter: postgresql
encoding: unicode
database: fls_development
host: localhost
pool: 5
port: 5432
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: postgresql
database: fls_test
pool: 5
timeout: 5000
default: &default
adapter: postgresql
encoding: unicode
pool: 5
也与此帖子类似:How to configure PostgresSQL server on MacOS 10.8.5?,当我只是postgres
postgres does not know where to find the server configuration file.
You must specify the --config-file or -D invocation option or set the PGDATA environment variable.
我很困惑,因为上述SO帖子的解决方案建议使用Homebrew安装,但我很确定我是如何安装它的。
答案 0 :(得分:2)
所以,这是一种间接解决方案,但我只是运行brew uninstall postgresql
然后安装了PostgreSQL应用程序,该应用程序在右端口5432上自动运行。
答案 1 :(得分:1)
之前我遇到过同样的问题,并通过这样做解决了这个问题
rm /usr/local/var/postgres/postmaster.pid
brew services restart postgresql