debugsqlMinor
psql won't list databases
Viewed 0 times
wonpsqllistdatabases
Problem
I have a situation that I'm scratching my head over, but I'm new to postgresql, so I may be overlooking something obvious.
I set up a testbed server and set access in pg_hba.conf:
Then restarted the postgresql server and after that, I could, as my regular user, use
And this gave me the table listing.
On the second system pg_hba.conf matches that other file. I restarted the database server process and yet psql -h localhost -U postgres -l as my user yields this error:
I do not have a password configured for that user. If I
Then try
...as postgres won't work, still prompting for a password, but if I use:
it gives the list of databases.
This server, the second one, has a "production" database on it that another developer set up. But he doesn't know why it wouldn't let me list it as my username with the -h host -U postgres arguments on that server, while the fresh-install on the first server will list them (although the first one has nothing but the default installation on it.)
The platform is Ubuntu 11.10, postgres is 9.1. Any idea what I'm overlooking?
EDIT
Here's what's happening when I try getting a database list:
```
user@testbed:/etc/postgresql/9.1/main$ grep listen_addresses *
grep: pg_hba.conf: Permission denied
grep: pg_ident.conf: Permission denied
postgresql.conf:#listen_addresses = 'loc
I set up a testbed server and set access in pg_hba.conf:
local all postgres peer
local all all md5
host all all 127.0.0.1/32 trust
host all all ::1/128 md5Then restarted the postgresql server and after that, I could, as my regular user, use
psql -h localhost -U postgres -lAnd this gave me the table listing.
On the second system pg_hba.conf matches that other file. I restarted the database server process and yet psql -h localhost -U postgres -l as my user yields this error:
2012-03-29 23:31:17 UTC LOG: could not receive data from client: Connection reset by peer
Password for user postgres:
psql: fe_sendauth: no password supplied
2012-03-29 23:31:29 UTC LOG: could not receive data from client: Connection reset by peerI do not have a password configured for that user. If I
sudo su - postgresThen try
psql -h localhost -U postgres -l...as postgres won't work, still prompting for a password, but if I use:
psql -lit gives the list of databases.
This server, the second one, has a "production" database on it that another developer set up. But he doesn't know why it wouldn't let me list it as my username with the -h host -U postgres arguments on that server, while the fresh-install on the first server will list them (although the first one has nothing but the default installation on it.)
The platform is Ubuntu 11.10, postgres is 9.1. Any idea what I'm overlooking?
EDIT
Here's what's happening when I try getting a database list:
```
user@testbed:/etc/postgresql/9.1/main$ grep listen_addresses *
grep: pg_hba.conf: Permission denied
grep: pg_ident.conf: Permission denied
postgresql.conf:#listen_addresses = 'loc
Solution
According to the pg_hba.conf snippet, a password is required if you connect from ::1, which is the IPv6 address for localhost.
It may be that the box on which you have the problem has the resolver configured so that the name "localhost" refers to both 127.0.0.1 (IPv4) and ::1 (IPv6), so that the command
I'd suggest to check the
It may be that the box on which you have the problem has the resolver configured so that the name "localhost" refers to both 127.0.0.1 (IPv4) and ::1 (IPv6), so that the command
psql -h localhost... may connect to one or the other address. I'd suggest to check the
/etc/hosts file for different localhost entries, or bypass the resolver by connecting to 127.0.0.1, or update the pg_hba.conf with "trust" for IPv6 local connections.Context
StackExchange Database Administrators Q#15836, answer score: 6
Revisions (0)
No revisions yet.