I think that, accidentally, I changed my user to a role with no log in allowed. Now I can't even log in to give log in privileges to the role. Is there something I can do?

I think there was only 1 user and I don't know how to list all my users if I can't log in first.



I reinstalled postgres and it seems that no postgres user exists. I installed it via brew:

users and roles according to psql


The main superuser account is set up by initdb when run and will default to the current system user name, not postgres, unless an explicit -u/--username argument is given. From your above \du output it's clear that when you set up the server you did it with your laygr system user as that user is the database server's main superuser account.

Should you mess up your login privileges or forget your password you can get back into the server if you have write access to it's data directory in order to be able to edit pg_hba.conf. Just change the auth-method on the relevant line to trust and reload the server's config via pg_ctl reload. You can then log in, fix your user/password, and then revert the changes you made to pg_hba.conf and reload the config again.


Use the default user postgres to login and re-enable your account. Sure, you need to know the postgres user's password...

  • Maybe it's because I installed postgres via brew, but there is no postgres user... – Lay González Jul 8 '17 at 20:02
  • 1
    As far I know, a postegres user is always present on a postgres installation. If you can not find it, try with user pgsql – shodanshok Jul 8 '17 at 20:05
  • I already reinstalled postgresql and I can say that when doing psql \l and psql \du no postgres user or role is shown. – Lay González Jul 8 '17 at 20:08
  • So, what users are shown on a fresh installation? – shodanshok Jul 8 '17 at 20:08
  • 1
    Ok, so you basically disabled/impaired your superuser account. I think re-installation is the only possibility in this case. However, I suggest you to ask on postgresql mailing list for more information. – shodanshok Jul 8 '17 at 20:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.