Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have made the following entry in pg_hba.conf

local all all trust

but still

su postgres

does not accept blank as password. I am not able to run psql nor pg_ctl for same reason as most of the files are owned by postgres.


dhaval@ubuntu:~$ su -c "pg_ctl reload -D template1"
su: Authentication failure

dhaval@ubuntu:~$ su -c psql
su: Authentication failure

I am giving the root password above but I guess its expecting "postgres" superuser password. I dont have the same. I need to reset it.


dhaval@ubuntu:~$ sudo -i -u postgres
[sudo] password for dhaval:
postgres@ubuntu:~$ psql
Welcome to psql 8.3.7, the PostgreSQL interactive terminal.

The above has taken me postgreSQL command prompt. But I am still not sure why the "trust" was not working.

share|improve this question
"trust" is working fine -- Postgres trusts you, the OS does not (you are not root, therefore when you try to su to postgres you must enter the postgres OS user's password) -- There are two different authentication stores, and two separate "users" here (one set for the OS and one for DB). Also note that you don't need to su to postgres (see the -U option to psql to specify a database username other than the currently-logged-in OS user) – voretaq7 Mar 1 '10 at 18:55
up vote 2 down vote accepted

Operating System User passwords (the thing you're asked for when you try to su) are not the same as Postgres User Passwords (the thing you don't need when you set auth to trust in pg_hba.conf).

You need to set a valid OS password for the Operating System's postgres user and enter that password in order to su to that user (Or su to that user from root, where you won't be asked for a password).

Typically the postgres OS user password is locked out after DB initialization since the only thing that needs to run as postgres is pg_ctl, which can be launched with su -c from your init scripts (that run as root and therefore don't need the password).

share|improve this answer
Yes, but to enter postgresql I need the postgres superuser password which I dont have. – dhaval Mar 1 '10 at 17:43

Most likely you are trying to do 'su postgres'. Ubuntu does not allow a non-root user to switch to another user. So you may need to assume root and then su postgres.

To become 'root', try:

sudo su -

After that, try:

su postgres

That should get you access as the 'postgres' user as understood by the OS.

Hope this helps.

best Vishal Belsare

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.