createdb: could not connect to database template1: fatal: password authentication failed for user "user1"

Viewed 1871

I just installed postgres. and then wrote the following commands in my terminal then

postgres@user /home/user $ createuser -dP CinemaHole

Enter password for new role:

Enter it again:

postgres@user /home/user $ createdb -E utf8 -U Movie CinemaHole

createdb: could not connect to database template1: FATAL: Peer authentication failed for user "Movie"

Here is my pg_hba.conf

pg_hba.conf Please help me with the issue.

1 Answers

First do not image links for file contents. Instead post the actual text. It makes it easier to include your information in the answer.

Second try:

createdb -E utf8 -U CinemaHole -h localhost Movie

Assuming CinemaHole is the user you really want to use.

The connection that is not working:

createdb -E utf8 -U Movie CinemaHole

is failing because you do not have a -h (host) name so it trying the local socket and your pg_hba.conf has peer authentication for local(socket) connections. Also you are doing -U Movie which is specifying the user Movie which is not what you created. Also user Movie is not the system user you are logged in as, so peer authentication is failing. The connection I suggested you try is using -h localhost and for that your pg_hba.conf use md5(password) authentication.

For more information on pg_hba.conf see here

FYI, you can also do the CREATE ROLE(USER) and CREATE DATABASE using the psql client. Fewer programs to remember.

Related