1

I have been using PostgreSQL for a couple of days and it has been working fine. I have been using it through both the default postgres database user as well as another user with permissions.

In the middle of the day today (after everything had been working fine) it stopped working and I could no longer get back into the database. I would try: psql and it would come up with psql: FATAL: role "postgres" does not exist.

Similarly, if I tried from my other user, psql -d postgres it would come up with psql: FATAL: role "otheruser" does not exist. (Note that I have a database named postgres and it has been working up until now).

UPDATE

It appears that one of the computers accessing the server crashed and may have somehow deleted all of the users of the database. I will try a fresh reinstall.

2 Answers 2

0

To check what users exist without being able to log in with psql, you can use the following method:

  • stop postgres
  • restart it in single user mode (specifying the data directory)
  • query the pg_user global table
  • restart postgres normally

Example:

$ sudo -i -u postgres
...
postgres@u64:/usr/local/pg95a1$ bin/postgres --single -D $PWD/data

PostgreSQL stand-alone backend 9.5alpha1
backend> select usename from pg_user;
     1: usename (typeid = 19, len = 64, typmod = -1, byval = f)
    ----
     1: usename = "postgres"    (typeid = 19, len = 64, typmod = -1, byval = f)
    ----
     1: usename = "daniel"  (typeid = 19, len = 64, typmod = -1, byval = f)
    ----
     1: usename = "joe" (typeid = 19, len = 64, typmod = -1, byval = f)
    ----
     1: usename = "bob" (typeid = 19, len = 64, typmod = -1, byval = f)
    ----

ctrlD to terminate the single-user session.

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

Comments

0

Roles postgres and other user might be dropped. If you have at least one user with superuser permissions you can create those roles again. Similar question referred here

3 Comments

Every time I try createuser --interactive it only comes back up with the same FATAL error.
Do \du in psql console and paste the output here please
I see. If you cant get into the psql console and cant run createuser or createdb that means probably you dont have any superuser roles left (or any roles for that matter). TBH I dont know what to do in this case. Try posting your question to dba . You will get better results there

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.