且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Rails:致命-用户的对等身份验证失败(PG :: Error)

更新时间:2021-11-13 08:31:30

如果在服务器上安装了postresql然后仅将host:localhost托管到database.yml,通常将其放在显示pool:5的地方。否则,如果不是localhost,请明确告诉该应用程序在哪里找到其数据库。

If you installed postresql on your server then just host: localhost to database.yml, I usually throw it in around where it says pool: 5. Otherwise if it's not localhost definitely tell that app where to find its database.

development:
  adapter: postgresql
  encoding: unicode
  database: kickrstack_development
  host: localhost
  pool: 5
  username: kickrstack
  password: secret

通过创建数据库并将所有权分配给您的应用程序用户以建立连接,确保正确设置了用户凭据。要在postgresql 9中创建新用户,请运行:

Make sure your user credentials are set correctly by creating a database and assigning ownership to your app's user to establish the connection. To create a new user in postgresql 9 run:

sudo -u postgres psql

如果没有,请设置postgresql用户密码,它只是反斜杠密码。

set the postgresql user password if you haven't, it's just backslash password.

postgres=# \password

创建一个新用户和密码,然后用户的新数据库:

Create a new user and password and the user's new database:

postgres=# create user "guy_on_***" with password 'keepitonthedl';
postgres=# create database "dcaclab_development" owner "guy_on_***"; 

在确认创建数据库,用户,密码和设置后,现在更新database.yml文件这些特权。不要忘记主机:本地主机。

Now update your database.yml file after you've confirmed creating the database, user, password and set these privileges. Don't forget host: localhost.