【发布时间】:2017-08-19 07:04:42
【问题描述】:
我在 SQlite 和 MySQL 中使用过 Rails。第一次使用 PostgreSQL。刚刚在我的本地机器上安装了 PostgreSQL。使用 Heroku 进行生产。
每次我运行 rake db:migrate 或 rake db:create 我都会收到以下错误:
PG::ConnectionBad: fe_sendauth: no password supplied
我使用 Homebrew 安装了 PostgreSQL,但从未设置用户或密码。 这是我的 Postgres 设置:
Daves-MBP-2:project dave$ ps aux | grep postgres
postgres 670 0.0 0.0 2466764 1816 ?? S Fri10AM 0:00.33 /System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Versions/A/Support/mdflagwriter
postgres 658 0.0 0.0 2514516 3032 ?? S Fri10AM 0:01.31 /usr/sbin/distnoted agent
postgres 657 0.0 0.0 2542724 6336 ?? S Fri10AM 0:05.69 /usr/libexec/trustd --agent
postgres 656 0.0 0.0 2545304 6676 ?? S Fri10AM 0:04.28 /usr/libexec/lsd
postgres 655 0.0 0.0 2515008 2596 ?? S Fri10AM 0:00.07 /usr/sbin/cfprefsd agent
postgres 240 0.0 0.0 2508940 920 ?? Ss Fri10AM 0:01.06 postgres: stats collector process
postgres 239 0.0 0.0 2653940 1860 ?? Ss Fri10AM 0:00.64 postgres: autovacuum launcher process
postgres 238 0.0 0.0 2653940 832 ?? Ss Fri10AM 0:01.00 postgres: wal writer process
postgres 237 0.0 0.0 2653940 900 ?? Ss Fri10AM 0:01.02 postgres: writer process
postgres 236 0.0 0.0 2653940 896 ?? Ss Fri10AM 0:00.04 postgres: checkpointer process
postgres 233 0.0 0.0 2508940 728 ?? Ss Fri10AM 0:00.00 postgres: logger process
postgres 108 0.0 0.0 2654196 3372 ?? Ss Fri10AM 0:00.32 /Library/PostgreSQL/9.6/bin/postmaster -D/Library/PostgreSQL/9.6/data
dave 68244 0.0 0.0 2442020 2012 s000 S+ 4:28PM 0:00.00 grep postgres
这是我的 database.yml 文件
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
adapter: postgresql
encoding: unicode
database: "mydatabase"
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3
production:
adapter: postgresql
encoding: unicode
url: "HEROKU URL"
这是我从 pg_hba.conf 中获得的设置 - cd /usr/local/var/postgres/ - 打开 pg_hba.conf
我错过了什么?
谢谢
编辑
以下是来自以下 cmets 的内容:
第一个文件“com.edb.launchd.postgresql-9.6.plist”:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>com.edb.launchd.postgresql-9.6</string>
<key>ProgramArguments</key>
<array>
<string>/Library/PostgreSQL/9.6/bin/postmaster</string>
<string>-D/Library/PostgreSQL/9.6/data</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>postgres</string>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
</dict>
</plist>
第二个文件“homebrew.mxcl.postgresql.plist”:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>homebrew.mxcl.postgresql</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/postgresql/bin/postgres</string>
<string>-D</string>
<string>/usr/local/var/postgres</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/usr/local</string>
<key>StandardErrorPath</key>
<string>/usr/local/var/log/postgres.log</string>
</dict>
</plist>
【问题讨论】:
标签: ruby-on-rails ruby postgresql heroku