Login to PostgreSQL - Login failed

Ivan Z. Horvat picture Ivan Z. Horvat · Mar 2, 2012 · Viewed 46.1k times · Source

I installed psql and phpPgAdmin to my Ubuntu11.10 and don't know how to run it. What is the default username and password?

Answer

Joachim Isaksson picture Joachim Isaksson · Mar 2, 2012

There is no default username and password without you creating one. The simplest possible setup is to follow these steps to set up your own user as a superuser.

At a terminal prompt, create a postgres user with your own username

sudo -u postgres createuser --superuser $USER

Start the postgresql command prompt as your username but running as root since you didn't set a password yet;

sudo -u postgres psql

At the postgresql prompt, set your password;

\password $USER

After that, you should be able to log on just fine.

The setup is more thoroughly documented here.

EDIT:

If you get stuck not being able to authenticate automatically as the postgres user, you may want to compare your /etc/postgresql/9.1/main/pg_hba.conf (ie authentication config file) with the following lines from mine that works; you can get the uncommented ones using

grep -v ^# pg_hba.conf

The "local" lines should be the essential ones in this case since you can't authenticate even from the same machine;

local   all             postgres                                peer
local   all             all                                     peer
host    all             all             127.0.0.1/32            md5
host    all             all             ::1/128                 md5