postgresql Ecto Postgres 安装错误密码认证失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35785892/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 02:11:32  来源:igfitidea点击:

Ecto Postgres install error password authentication failed

postgresqlphoenix-frameworkecto

提问by Robert Kass

I created a phoenix project from the hello example using digital ocean. I entered the username and password from the etc/motd.tail file. I keep getting the error message below. I am a beginner and for some reason I just cannot get ecto to install correctly.

我使用数字海洋从 hello 示例创建了一个凤凰项目。我从 etc/motd.tail 文件中输入了用户名和密码。我不断收到以下错误消息。我是初学者,出于某种原因,我无法正确安装 ecto。

** (Mix) The database for Hello.Repo couldn't be created, reason given: psql: FATAL: password authentication failed for user "elixir" FATAL: password authentication failed for user "elixir"

** (Mix) 无法创建 Hello.Repo 的数据库,原因如下: psql: FATAL:用户“elixir”的密码验证失败 FATAL:用户“elixir”的密码验证失败

You can use the following Postgress database credentials: * User: elixir * Pass: ***

您可以使用以下 Postgress 数据库凭据: * 用户:elixir * 通行证:***

install. Any help would be appreciated.

安装。任何帮助,将不胜感激。

采纳答案by Gazler

I assume this error is happening on the mix ecto.createtask?

我假设这个错误发生在mix ecto.create任务上?

This happens because Ecto uses psqlto create the database, however this is no longer the case in the upcoming Ecto 2.0.

发生这种情况是因为 Ecto 用于psql创建数据库,但是在即将推出的 Ecto 2.0 中不再是这种情况。

The following GitHub issue shows the same issue https://github.com/elixir-lang/ecto/issues/1207

以下 GitHub 问题显示了相同的问题https://github.com/elixir-lang/ecto/issues/1207

The relevant comment with the fix is https://github.com/elixir-lang/ecto/issues/1207#issuecomment-172570064:

修复的相关评论是https://github.com/elixir-lang/ecto/issues/1207#issuecomment-172570064

My database config (pg_hba.conf) was apparently wrong.

For anyone else encountering this:

host all my_user 127.0.0.1/32 trust will not work host all my_user localhost trust will work

我的数据库配置 (pg_hba.conf) 显然是错误的。

对于遇到此问题的其他人:

托管所有 my_user 127.0.0.1/32 信任将不起作用 托管所有 my_user localhost 信任将起作用

Please check your pg_hba.conf(likely in /etc/postsgresql/9.x/pg_hba.conf).

请检查您的pg_hba.conf(可能在/etc/postsgresql/9.x/pg_hba.conf)。

回答by Isa Souza

I get the same error using Ubuntu 14.04 and I corrected resetting the 'postgres' password:

我在使用 Ubuntu 14.04 时遇到了同样的错误,我更正了重置“postgres”密码:

$ sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"

and restart postgres service:

并重启 postgres 服务:

sudo service postgresql restart

回答by Fillype Farias

We just need to create a new postgresql usernameand passwordaccording to the files inside configfolder using this db method

我们只需要创建一个新的 postgresqlusernamepassword根据config使用此 db 方法的文件夹中的文件

$ sudo -u postgres createuser <username>
$ sudo -u postgres createdb <dbname>
$ sudo -u postgres psql
psql=# alter user <username> with encrypted password '<password>';
psql=# grant all privileges on database <dbname> to <username> ;

回答by Sergio Ocón-Cárdenas

I needed to update the pg_hba.conf to make this work.

我需要更新 pg_hba.conf 才能完成这项工作。

I am using Fedora, so get to /var/lib/pgsql/data

我正在使用 Fedora,因此请访问 /var/lib/pgsql/data

# "local" is for Unix domain socket connections only
local   all             postgres                                peer
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 ident

Then I created an elixir user in postgres with databse creation capabilities and configured it in dev.exs (user/password/database)

然后我在具有数据库创建功能的 postgres 中创建了一个 elixir 用户,并在 dev.exs(用户/密码/数据库)中进行了配置