I have installed PostgreSQL 9.1 on my PC (Win 7). I have a small Java application connecting successfully to it with login=sa
and password=""
. The connection works.
However, it is refused from PgAdmin III itself. I get:
Error connecting to the server: fe_sendauth: no password supplied
How do I connect to my database from PgAdmin III with an empty password?
EDIT
This is just a test, not production code.
-
I don't know for sure, but it's easy to imagine that PgAdmin doesn't support that.Peter Eisentraut– Peter Eisentraut2011年11月09日 19:02:27 +00:00Commented Nov 9, 2011 at 19:02
-
is your Java app on the same client as pgAdmin?Jack Douglas– Jack Douglas2011年11月19日 11:54:21 +00:00Commented Nov 19, 2011 at 11:54
-
similar questionJack Douglas– Jack Douglas2011年11月19日 12:04:09 +00:00Commented Nov 19, 2011 at 12:04
2 Answers 2
I can connect to my postgres instance from pgAdmin III without a password for any user including superusers such as postgres
.
Because you are connecting ok from another client, there is no reason you should not be able to connect from pgAdmin if they are on the same workstation - unless some firewall rule on the client itself is allowing one program but not another.
If the problem is specific to this client, you may need to change one or more of:
- pg_hba.conf
host sa all 192.168.0.nnn/32 trust
- postgresql.conf
listen_addresses = '*'
- the firewall on your postgres server, eg iptables:
-A INPUT -s 192.168.0.nnn -m state --state NEW -j ACCEPT
But I recommend you don't do any of this. The manual says the following with good reason:
trust authentication is only suitable for TCP/IP connections if you trust every user on every machine that is allowed to connect to the server by the pg_hba.conf lines that specify trust. It is seldom reasonable to use trust for any TCP/IP connections other than those from localhost (127.0.0.1).
Instead, consider either:
- using a password and md5 identification
- tunnelling port 5432 over ssh
I found this answer elsewhere.
If your DB is on the local host, try leaving the host field blank in the connection as opposed to using "localhost" or "127.0.0.1′′. This tells PgAdmin to connect via the local unix socket instead of TCP.
-
Let's add that the original question was about a Windows system.András Váczi– András Váczi2012年12月11日 08:38:11 +00:00Commented Dec 11, 2012 at 8:38
-
3Ah this was exactly it. Leaving host blank worked.basicdays– basicdays2015年04月11日 02:22:12 +00:00Commented Apr 11, 2015 at 2:22
-
2You cannot leave this field blank, it is required.Athlan– Athlan2015年04月17日 13:18:12 +00:00Commented Apr 17, 2015 at 13:18
-
It looks like leaving the host field blank works only if you have a role in pg named as your system username (on Linux). Otherwise I guess user maps are needed.a1an– a1an2015年08月31日 12:25:05 +00:00Commented Aug 31, 2015 at 12:25
-
1Perfect! With a fresh install of postgresql and pgadmin, changing
pg_hba.conf
to saytrust
instead ofpeer
in this line -local all postgres trust
, and leaving the host and password fields blank in pgadmin gets everything working! I wish pgadmin would add a checkbox to switch to sockets instead of this hard to discover UI.user113443– user1134432016年12月22日 05:01:44 +00:00Commented Dec 22, 2016 at 5:01