0

I've installed PostgreSQL 9.3 in Ubuntu and I've created a new user "myuser". In fact if I write psql -U postgres -c'\du+' I get

                                    List of roles
Role name |                   Attributes                   | Member of |  Description 
----------+------------------------------------------------+-----------+-------------
postgres  | Superuser, Create role, Create DB, Replication | {}        | 
myuser    |                                                | {}        | 

Now I want to modify the password for "myuser" and then create a new database. So I wrote

psql \password myuser
Password for user myuser: bla bla...

but I get the error

psql: FATAL:  password authentication failed for user "myuser"

but I don't remember to have created a previous password. Ok, no problem. I decide to delete this user and so I wrote:

dropuser myuser
Password: what? bla bla...
dropuser: could not connect to database postgres: FATAL: password authentication failed for user "strange_user"

strange_user is a fancy name... but I don't know who is... There's a way to fix this issue?

My pg_hba.conf is:

# Database administrative login by Unix domain socket
local   all             postgres                                md5

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
2
  • Could you post your pg_hba.conf ? Commented Nov 12, 2015 at 14:50
  • yep, I edit the original message Commented Nov 12, 2015 at 15:05

1 Answer 1

1

I think your problem might be that portgres doesn't know what postgres role (user) you want to connect as when you try to set the password or drop the user.

Try something like `psql -U postgres -c "ALTER ROLE myuser ENCRYPTED PASSWORD 's3kr1t'.

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

7 Comments

I get psql: FATAL: database "ALTER ROLE myuser ENCRYPTED PASSWORD 's3kr1t'" does not exist.
I have added an option (-c) to the command that should solve that.
ok it seem to work. but just let me understand. In this way I simply change the password for myuser and set it as s3kr1t (or whatever I want)? Eventually there's a way to be sure that the password set is correct?
Just connect as myuser to be sure the password is as you expect.
And how can I connect me as myuser?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.