Fe_sendauth: 没有提供密码

Yml:

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
development:
adapter: postgresql
encoding: utf8
database: sampleapp_dev  #can be anything unique
#host: localhost
#username: 7stud
#password:


#adapter: sqlite3
#database: db/development.sqlite3
pool: 5
timeout: 5000


# 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:
adapter: postgresql
encoding: utf8
database: sampleapp_test  #can be anything unique
#host: localhost
#username: 7stud
#password:
#adapter: sqlite3
#database: db/test.sqlite3
pool: 5
timeout: 5000


production:
adapter: postgresql
database: sampleapp_prod   #can be anything unique
#host: localhost
#username: 7stud
#password:
#adapter: sqlite3
#database: db/production.sqlite3
pool: 5
timeout: 5000

Pg _ hba. conf:

# TYPE  DATABASE        USER            ADDRESS                 METHOD


# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     postgres                                md5
#host    replication     postgres        127.0.0.1/32            md5
#host    replication     postgres        ::1/128                 md5

我将前三行中的方法从 md5更改为 trust,但是仍然得到错误。

不管我在 datase.yml 中尝试什么组合,当我这样做时:

~/rails_projects/sample_app4_0$ bundle exec rake db:create:all

我总是得到错误:

Fe _ sendauth: 没有提供密码

我按照这个教程来设置:

Https://pragtob.wordpress.com/2012/09/12/setting-up-postgresql-for-ruby-on-rails-on-linux

Mac OSX 10.6.8
PostgreSQL 9.2.4 installed via enterpriseDB installer
Install dir: /Library/PostgreSQL/9.2
344175 次浏览

After making changes to the pg_hba.conf or postgresql.conf files, the cluster needs to be reloaded to pick up the changes.

From the command line: pg_ctl reload

From within a db (as superuser): select pg_reload_conf();

From PGAdmin: right-click db name, select "Reload Configuration"

Note: the reload is not sufficient for changes like enabling archiving, changing shared_buffers, etc -- those require a cluster restart.

I just put --password flag into my command and after hitting Enter it asked me for password, which I supplied.

This occurs if the password for the database is not given.

default="postgres://postgres:password@127.0.0.1:5432/DBname"

psql -U postgres --password


Password:<Enter your password>

Then this will appear. postgres=#

This worked for me

I also had same issue. But my application was running on docker daemon. I changed those environment in docker-compose.yml file. And also changed in database.yml file. These changes resolved my issue.

 DATABASE_HOST= db
POSTGRES_PASSWORD= password

What worked for me was making sure that I had these four lines after development, test, and production in the database.yml file. I leave username and password blank here for security purposes, but fill these out in the actual application

  username:
password:
host: localhost
port: 5432