【问题标题】:Setting Up PostgreSQL for initial use on Mac OS在 Mac OS 上设置 PostgreSQL 以供初始使用
【发布时间】:2012-06-08 20:09:39
【问题描述】:

我已经在我的本地 mac 上安装了 PostgreSQL 9,它安装了“SQL Shell (psql).app”,我认为它是服务器的命令 shell。我已经打开它,但它要求Username [postgres]:。我输入 postgres 然后它要求输入密码。我按回车,它给出了以下错误:
psql: fe_sendauth: no password supplied

如何登录,更重要的是如何运行createdb 之类的命令?我在正常的终端窗口中尝试了createdb 命令,但无法识别该命令。

我应该使用 Homebrew 还是 Macports?我没有使用过这些都是 Mac OS 的新手

感谢您的帮助!

【问题讨论】:

  • 你用的是什么安装方式?
  • 我下载并安装了 postgresql-9.0.4-1-osx.dmg

标签: macos postgresql


【解决方案1】:

我遇到了这个问题,从 database.yml 中删除主机和端口参数为我解决了这个问题:

development:
  adapter: postgresql
  encoding: unicode
  database: my_db
  pool: 5
  host: localhost # remove this line
  port: 5432 # and this one

【讨论】:

    【解决方案2】:

    如果您的 postgres 用户没有密码,请设置此环境变量:

    export PGPASSWORD=
    

    【讨论】:

    • 我在哪里做这个?抱歉,我一般是 Unix 新手