macos - 尝试在 OSX 上设置 postgres

标签 macos postgresql

<分区>

我正在尝试在我的 Mac (10.7 Lion) 上为 Rails 应用程序在本地设置 postgres。

我安装了 postgresapp并启动它,现在我的状态栏中有一只大象告诉我 postgres 正在运行。

我可以通过:

psql -h localhost

但是当我简单地运行 psql 时,我得到了这个错误:

psql: 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"?

我把这个:

PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"

~/.bashrc 中打开一个新的终端。但是没有骰子。

当我运行 which psql 时,我得到 /usr/bin/psql

不太确定该怎么做。我对 unix 系统还是很陌生。我应该将 /usr/bin/psql 符号链接(symbolic link)到 /Applications/Postgres.app/Contents/MacOS/bin/psql 吗?

最佳答案

我在运行 Mountain Lion 的新 MacBook Pro 上遇到了类似的问题。我下载了 PostgresApp当我启动 rails 时,我收到以下错误:

`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"?

为了解决这个问题,我必须在我的 database.yml 文件中明确定义主机和端口,如下所示:

development:
  adapter: postgresql
  encoding: unicode
  database: my_app_development
  pool: 5
  username: tony
  password: stark    
  host: localhost
  port: 5432

关于macos - 尝试在 OSX 上设置 postgres,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11980017/

相关文章:

eclipse - eclipse中是否有刷新项目的键盘快捷键?

xcode - 从 MainMenu.xib 初始化 NSObject

macos - MAC : missing: ZLIB_INCLUDE_DIR && OPENGL_INCLUDE_DIR

mysql - 同一个表中相关项的 SQL 查询

postgresql - 它可以引用 PL/pgSQL 变量或表列

MySql 到 PostgreSql 迁移

postgresql - 适用于 Windows 的良好 Postgres 图形客户端

python - read() 的文件大小限制?

macos - 一致 "-repeat watch"不工作

python - 从 Python 中的字符串推断适当的数据库类型声明