0

I'm trying to create a user from command line using PostgreSQL version 9.4 on a 64 bit machine with windows.

I'm using the below command to create a new user:

createuser -d temba

On executing the above command, it prompts me for a password. I enter the password (qwerty) which i used while installing PostgreSQL. on doing so, i get the below error:

psql: FATAL:  password authentication failed for user "my-windows-user-name"

Next, i tried giving my login password for windows, i get the same error as above.

Can anyone guide me through the procedure for creating a new user from command line (only, I'm not allowed to use PgAdmin to create user).

I have checked previous posts with similar errors. But the problem there is, either they are not using windows or they are using a really old version of PostgreSql.

Any information on how to proceed about with this shall be really helpful.

Thanks in advance.

1 Answer 1

4

All Postgres command line tools try to connect to the database using the current operating system user if no database user is specified.

So you need to specify the user name of the Postgres superuser that is used to connect to the Postgres server:

createuser -U postgres -d temba

This becomes more evident if you use psql instead. You specify the Postgres user account and the target database when you start it:

psql -U postgres -d temba

Then at the prompt you can run create user ....

temba=# create user foobar ... ; 

Which is what the command line tool createuser is doing in the background.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.