database.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
我将前三行中的METHOD从md5改为trust,但我仍然得到错误。
无论我在database.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
答案 0 :(得分:54)
更改pg_hba.conf
或postgresql.conf
文件后,需要重新加载群集以获取更改。
从命令行:pg_ctl reload
来自db(作为超级用户):select pg_reload_conf();
从PGAdmin:右键单击数据库名称,选择“重新加载配置”
注意:重新加载不足以进行更改,例如启用存档,更改shared_buffers
等 - 这些都需要重新启动群集。
答案 1 :(得分:0)
我只是将--password
标志放入命令中,然后按Enter,它要求我提供密码。
答案 2 :(得分:0)
如果未提供数据库密码,则会发生这种情况。
default="postgres://postgres:password@127.0.0.1:5432/DBname"
答案 3 :(得分:0)
psql -U postgres --password
Password:<Enter your password>
然后就会出现这个。 postgres=#
这对我有用
答案 4 :(得分:0)
您可以使用这些代码停止和重新启动 postgres 服务器
export const authEpic = (action$) =>
action$.pipe(
ofType('AUTH_LOGIN_REQUEST'),
// Note this is now `map` instead of `switchMap`
map(({ authData }) => {
const user = users.find(
(user) =>
authData.email === user.email && authData.password === user.password
);
// Some how handle no match (e.g. wrong email or password)
if (!user) {
return { type: 'NO_RESULTS' };
}
return { type: 'RESULTS', results: user };
})
);
答案 5 :(得分:-1)
不要使用密码。改用 peer authentication:
postgres://myuser@%2Fvar%2Frun%2Fpostgresql/mydb