Cannot create superuser in postgres 14 WSL / Linux - Terminal

175 Views Asked by At

After i try $ sudo -u postgres createuser --interactive

it promts me with the name and superuser option (which I say yes)

then I get this error

createuser: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: role "my-user" does not exist

my-user is the name I gave it when prompted for a name and it is the same user I have on the WSL terminal, I have done this previously with no problem so I don't think it matters.

I am a little bit lost on what the problem even is. I don't know if the problem is the linux user or the user being created in postgres

I also have searched for solutions but none land quite the same way as mine is landing

Help or guidence would be apretiated!

I have tried givin the folder permissions, I have tried re-installing postgres, rebooting

Following this post mostly How do I solve this problem to use psql? | psql: error: FATAL: role "postgres" does not exist

por it does nothing

The first time i did it i got this error instead could not change directory to "/home/user" which i solved with this https://dba.stackexchange.com/questions/54242/cannot-start-psql-with-user-postgres-could-not-change-directory-to-home-user

1

There are 1 best solutions below

2
andresnb On

After looking into it more and trying more solutions the problem was the first install that created a user without folder permission and it was like "hanging there doing nothing" Could not drop it, assign a role or anything.

The solution was to uninstall psql COMPLETELY following this post: kb.objectrocket.com/postgresql/…

After that reinstalling following this: postgresql.org/download/linux/ubuntu