postgresql createdb: 无法连接到数据库模板 1: 致命: 用户密码验证失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20692100/
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 01:14:08  来源:igfitidea点击:

createdb: could not connect to database template1: FATAL: password authentication failed for user

postgresqlterminalruby-on-rails-4homebrewpostgresql-9.2

提问by Mike Adeleke

Installed Postgresql via Homebrew. I wanted to create a new database after unzipping a ".tar". But I have this problem.

通过 Homebrew 安装了 Postgresql。我想在解压缩“.tar”后创建一个新数据库。但我有这个问题。

Michael-Adelekes-MacBook:wikiful madeleke13$ sudo su postgres -c 'createuser-P--superuser madeleke13'

bash: createuser-P--superuser: command not found

Michael-Adelekes-MacBook:wikiful madeleke13$ sudo su postgres -c 'createuser-P-superuser madeleke13'

bash: createuser-P-superuser: command not found

Michael-Adelekes-MacBook:wikiful madeleke13$ sudo su postgres -c 'createuser -P --superuser madelek13'

Password: Enter password for new role: Enter it again:

Michael-Adelekes-MacBook:wikiful madeleke13$ createdb -T template0

newdbPassword:
Password:

createdb: could not connect to database template1: FATAL: password authentication failed for user "madeleke13"

Michael-Adelekes-MacBook:wikiful madeleke13$

Michael-Adelekes-MacBook:wikiful madeleke13$ sudo su postgres -c 'createuser-P--superuser madeleke13'

bash: createuser-P--superuser: 命令未找到

Michael-Adelekes-MacBook:wikiful madeleke13$ sudo su postgres -c 'createuser-P-superuser madeleke13'

bash:createuser-P-superuser:找不到命令

Michael-Adelekes-MacBook:wikiful madeleke13$ sudo su postgres -c 'createuser -P --superuser madelek13'

密码:输入新角色的密码:再次输入:

Michael-Adelekes-MacBook:wikiful madeleke13$ createdb -T template0

newdb
密码: 密码:

createdb:无法连接到数据库模板 1:致命:用户“madeleke13”的密码身份验证失败

Michael-Adelekes-MacBook:wikiful madeleke13$

I am not understanding why I'm unable to authenticate my username when I have had no problems before.

我不明白为什么我以前没有问题时无法验证我的用户名。

回答by Penn Taylor

The issue is the username in this command: sudo su postgres -c 'createuser -P --superuser madelek13'

问题是此命令中的用户名: sudo su postgres -c 'createuser -P --superuser madelek13'

Notice the username not the same as the user's account name: madeleke13. There's an 'e' missing in the username provided to the createuser command, thus the failed authentication.

注意用户名与用户的帐户名不同:madeleke13。提供给 createuser 命令的用户名中缺少“e”,因此身份验证失败。