PostgreSQL password issue with psql

postgresqlpsql

I'm trying to setup PostgreSQL onto a CentOS (that I connect through SSH). I need to unzip a package (so not downloading through yum or rpm): http://get.enterprisedb.com/postgresql/postgresql-9.3.4-3-linux-x64-binaries.tar.gz and set this up.

I unzipped, and ran the following

./postgresql-9.3/bin/initdb -D data/
./postgresql-9.3/bin/postgres -D data/

When I try to run ./postgresql-9.3/bin/psql or createuser I get asked for a password and I enter it, but get:
psql.bin: FATAL: password authentication failed for user "myusername"

Question: How can I make psql and createuser work?

Additional info

My ./data/pg-hba.conf is as follows:

local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust

Also, there doesn't seem to be a postgres user in the system, which makes sense since I simply unzip the tar.gz

Best Answer

First, postgres users and your operating system users are not the same thing, except by default.

Unless you create an actual postgres system account on your computer, you will need to edit your pg_hba.conf file and set up your authentication methods. The default should have a line something like

local   all             postgres                                peer

Which tells it to let the postgres super user log in locally if the person running psql is using an operating system account also named postgres. If you change peer to trust then it will allow anyone to log in locally with psql -U postgres. Once you can connect, you'll be able to create other users with their passwords.

Once things are set up, for security you should set a password on the postgres user, then change trust to md5 to require the password to connect.