postgresql pgadmin 给了我错误:没有提供密码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14035742/
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
pgadmin gives me the error: no password supplied
提问by DarkCoffee
I've installed postgresql 9.2 on linux (kubuntu) and the last version of pgadmin3, but when I connect them I have this error:
我已经在 linux (kubuntu) 和最新版本的 pgadmin3 上安装了 postgresql 9.2,但是当我连接它们时出现以下错误:
An error has occurred: Error connecting to the server: fe_sendauth: no password supplied
发生错误:连接到服务器时出错:fe_sendauth:未提供密码
What can I do?
我能做什么?
I have also configured tomcat for my web application in java. In fact, postgresql was working before trying my application.
我还在 java 中为我的 web 应用程序配置了 tomcat。事实上,在尝试我的应用程序之前,postgresql 已经开始工作了。
采纳答案by Erwin Brandstetter
Whether a password is required depends on your settings in pg_hba.conf
. And there are different ways you can connect - different settings in pg_hba.conf may apply.
是否需要密码取决于您在 中的设置pg_hba.conf
。并且有不同的连接方式 - pg_hba.conf 中的不同设置可能适用。
I quote the help shipped with pgAdmin 3 for the "Host" field in the connection ("server") settings:
我引用了 pgAdmin 3 附带的帮助,用于连接(“服务器”)设置中的“主机”字段:
The host is the IP address of the machine to contact, or the fully qualified domain name. On Unix based systems, the address field may be left blank to use the default PostgreSQL Unix Domain Socket on the local machine, or be set to an alternate path containing a PostgreSQL socket. If a path is entered, it must begin with a “/”. The port number may also be specified.
主机是要联系的机器的 IP 地址,或完全限定的域名。在基于 Unix 的系统上,地址字段可以留空以使用本地机器上的默认 PostgreSQL Unix 域套接字,或者设置为包含 PostgreSQL 套接字的备用路径。如果输入路径,它必须以“/”开头。也可以指定端口号。
If you connect via Unix socket the rules for "local" apply. Whereas when connecting via TCP/IP "host" (or "hostssl") rules applies.
如果您通过 Unix 套接字连接,则“本地”规则适用。而通过 TCP/IP 连接时,“主机”(或“hostssl”)规则适用。
If you have a line like this at the top your pg_hba.conf file:
如果您的 pg_hba.conf 文件顶部有这样一行:
local all all peer
or:
或者:
local all all ident
.. then you can connect locally without password if your system user is "postgres" and your database user is "postgres", too.
.. 如果您的系统用户是“postgres”并且您的数据库用户也是“postgres”,那么您可以在没有密码的情况下进行本地连接。
回答by bbuckley123
I realize this is question is years old, but I ran into this same problem today and have a solution that uses trust
in a limited but useful way.
我意识到这个问题已经存在多年了,但我今天遇到了同样的问题,并且有一个trust
以有限但有用的方式使用的解决方案。
As in many development shops, when the devs need a QA postgres password, they just yell it, message it, email it, write it on their foreheads, etc. And I'm like, "This is really bad. I need to figure out a way to use PKI here." We also use pgAdmin3.
就像在许多开发商店一样,当开发人员需要 QA postgres 密码时,他们只是大喊大叫、发消息、通过电子邮件发送、写在他们的额头上等等。我想,“这真的很糟糕。我需要弄清楚一种在这里使用 PKI 的方法。” 我们也使用 pgAdmin3。
First, add a line like this to your pg_hba.conf, where dev
represents the user for the developers in your shop:
首先,在您的 pg_hba.conf 中添加这样的一行,其中dev
代表您商店中开发人员的用户:
host all dev 127.0.0.1/32 trust
host all dev 127.0.0.1/32 trust
Drop the developers' public key in their authorized_keys
folder on the database server. Now have them ssh into the server with the -L
flag with a command similar to the following:
将开发人员的公钥放入authorized_keys
数据库服务器上的文件夹中。现在让他们-L
使用类似于以下命令的标志ssh 进入服务器:
ssh -i ~/.ssh/id_rsa -L5432:127.0.0.1:5432 -vvv 101.102.103.104
ssh -i ~/.ssh/id_rsa -L5432:127.0.0.1:5432 -vvv 101.102.103.104
This allows one to use the postgres port as if it were localhost. Of course, replace the key, server and make sure to map to an open port locally (if you have a local postgres running, it's probably bound to 5432). I use a pretty verbose flag so I can easily troubleshoot any ssh issues.
这允许人们像使用本地主机一样使用 postgres 端口。当然,更换密钥、服务器并确保映射到本地开放端口(如果您有本地 postgres 运行,它可能绑定到 5432)。我使用了一个非常详细的标志,所以我可以轻松地解决任何 ssh 问题。
Open another terminal and issue this command:
打开另一个终端并发出以下命令:
psql -h 127.0.0.1 -U dev -p 5432
psql -h 127.0.0.1 -U dev -p 5432
You should have access to the database and never be prompted for a password, which I think is great because otherwise, the devs will just waive the password around with little regard to security, passing it out like Halloween candy.
您应该有权访问数据库并且永远不会被提示输入密码,我认为这很好,因为否则,开发人员将几乎不考虑安全性而放弃密码,像万圣节糖果一样传递密码。
As of now, PgAdmin3 will still prompt you for a password, even though -- plain as day -- you do not need it. But other postgres GUIs will not. Try Postico. It's in beta but works great.
到现在为止,PgAdmin3 仍然会提示您输入密码,即使 - 就像白天一样 - 您不需要它。但其他 postgres GUI 不会。试试 Postico。它处于测试阶段,但效果很好。
I hope this answer helps anyone like me who would rather use PKI for postgres auth rather than sharing passwords willy-nilly.
我希望这个答案可以帮助像我这样宁愿使用 PKI 进行 postgres 身份验证而不是随意共享密码的人。
回答by zhazha
Met this problem recently.
最近遇到这个问题。
If you're using PostgreSQL on local machine, and psql works well without logging needed, try pgadmin3's menu File - Add Server - Properties tab
, fill in Name
field for this connection, leave Host
field and Password
field empty, and click ok
.
如果您在本地机器上使用 PostgreSQL,并且 psql 在不需要日志记录的情况下运行良好,请尝试 pgadmin3 的 menu File - Add Server - Properties tab
,填写Name
此连接的Host
字段,将字段和Password
字段留空,然后单击ok
。
from pgadmin docs
On Unix based systems, the address field may be left blank to use the default PostgreSQL Unix Domain Socket on the local machine, or be set to an alternate path containing a PostgreSQL socket. If a path is entered, it must begin with a “/”.
在基于 Unix 的系统上,地址字段可以留空以使用本地机器上的默认 PostgreSQL Unix 域套接字,或者设置为包含 PostgreSQL 套接字的备用路径。如果输入路径,它必须以“/”开头。
Worked on Debian testing (pgadmin3 1.22, PostgreSQL 11), without touching pg_hba.conf
.
从事 Debian 测试(pgadmin3 1.22,PostgreSQL 11),没有接触pg_hba.conf
.