Postgresql fe_sendauth:未提供密码
database.yml:Postgresql fe_sendauth:未提供密码,postgresql,ruby-on-rails-4,Postgresql,Ruby On Rails 4,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: loca
# 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,但仍然得到错误
无论我在database.yml中尝试什么组合,当我这样做时:
~/rails_projects/sample_app4_0$ bundle exec rake db:create:all
我总是会出错:
fe_sendauth:未提供密码
我按照本教程进行设置:
对pg_hba.conf或postgresql.conf文件进行更改后,需要重新加载集群以获取更改 从命令行:pg_ctl reload 作为超级用户在数据库中:选择pg_reload_conf 从PGAdmin:右键单击数据库名称,选择重新加载配置
注意:重新加载不足以进行更改,如启用存档、更改共享缓冲区等,这些更改需要重新启动群集。我刚刚在命令中输入了-password标志,点击Enter键后,它向我询问我提供的密码。如果未提供数据库密码,则会发生这种情况 违约=postgres://postgres:password@127.0.0.1:5432/DBname 不要使用密码。改用: 然后这将出现。博士后=
这对我很有效您可以使用这些代码停止并重新启动postgres服务器
sudo service postgresql stop
sudo service postgresql start
您在进行更改后重新加载了pg_hba.conf文件?@bma,如何重新加载?我能够连接到服务器的唯一方法是在9.2目录中使用PGAdmin3。我选择服务器,右键单击,然后选择连接。因此,在尝试重新加载conf文件时,我在pgAdmin3中断开了与服务器的连接,然后重新连接。您可以发出一个查询:选择pg_reload_conf作为超级用户,或者在pgadmin中,您可以右键单击数据库名称,然后单击reload Configuration,我认为这就是原因,我不使用pgadmin@bma, !$@%!$^%! 成功了。你能把你的意见写在回答中吗?我也有同样的问题。我解决了将用户名:postgres和密码:放入我的数据库的问题。我有一个后续问题:据我所知,我从未启动过任何服务器。我做的唯一一件事就是用MacOSX安装程序安装postgress。然后我花了几个小时试图弄明白如何在没有运气的情况下使用postgres。我刚好在/Library/PostgreSQL/9.2目录中找到了pgAdmin3,所以我点击了它。那么服务器是如何启动的呢?我需要停止它吗?它可能是在安装程序完成安装后开始的。我见过的大多数安装程序/软件包都是这样做的。我需要停止它吗?我该怎么做?我不喜欢安装程序,因为我习惯于使用命令行。停止什么?数据库群集,还是安装程序?如果是后者,我不知道为什么安装程序仍在运行。服务器…但我找到了答案。我在这里写下了我让postgres使用rails的所有步骤:对我来说非常有用,只是在命令末尾添加了这一点,然后按enter!
postgres://myuser@%2Fvar%2Frun%2Fpostgresql/mydb
psql -U postgres --password
Password:<Enter your password>
sudo service postgresql stop
sudo service postgresql start