Super User is a question and answer site for computer enthusiasts and power users. 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 recently installed PostgreSQL on windows 7, each time i try to use CMD to execute SQL command, i get this error

createdb: could not connect to database template1: FATAL: password authentication failed for user "R-61"

Where R-61 is my windows machine username.

Here is how i use CMD with pgSQL

  • first i cd to the pgSQL bin folder $ cd C:\xampp\pgsql\9.1\bin
  • i try creating a database $ createdb NEWDATABASE
  • i get a prompt to enter a password. this is where am confuse as i do not know what password. I have tried my window user password, password for the postgres super user, none seem to work. this is the error message i get createdb: could not connect to database template1: FATAL: password authentication failed for user "R-61"

    Anybody know the solution to this? am thinking changing the user form R-61 to postgres superuser would work but i do not know how to do it.

Your help is greatly needed.

share|improve this question

migrated from May 23 '14 at 21:33

This question came from our site for system and network administrators.

up vote 1 down vote accepted

createdb is a command that has to connect to the server just like any other client command (even when run on the server itself), and as such requires a database user to connect with.

If you don't specify a database user with -U username option, it takes your OS username, hence the reference to "R-61" in the error message. The password that is asked is the password of a non-existing R-61 database user.

There are also other options such as the host defaulting to localhost and the port defaulting to 5432, see its manual page for all of them.

Since you mention that you know the postgres superuser password, the simplest solution would be to use the postgres user to initiate the command. It makes sense anyway, because on a fresh install this user would the only one that has the permission to create a database.

Try createdb -U postgres newdatabase

It should ask for a password, and that will be the password of the postgres database user.

If it doesn't ask for a password, it means that the security policy in pg_hba.conf is configured that way. If the password is lost (or no password has ever been set, which is the case for some automated installs, especially on Unix), pg_hba.conf has to be changed and the service reloaded to authorize passwordless connections, at least temporarily to set a new password.

share|improve this answer
A glance through PG manual should have answered my question. Thanks dude for saving my ass – Collizo4sky Jul 18 '14 at 22:30

I don't have direct experience with this but I looked into it and I think this is what you're looking for. I found a similar issue that suggests that PostgresSQL on Windows asks for a password during install. That password is probably the password for the administrator account for PostgresSQL. The admin account should work to connect to that database and adjust the permissions for it.

Alternatively, editing the pg_hba.conf file to trust user connections from certain users and locations should let you connect as well. You will want to correct the permission issue and revert the edited pg_hba.conf lines.

The discussion I found this on: Re: Default password Documentation on the pg_hba.conf file: 19.1. The pg_hba.conf File

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .