Mi Cie
Mi Cie

Reputation: 1

Finding postgres user password, that wasn't set up during installation

I'm following steps from this site: PostgreSQL Fedora tutorial

and despite not being asked to set up password for the postgres user at any point, postgres suddenly requires it:

[postgres@B8-64-F1-BE-62-20 ~]$ sudo systemctl restart postgresql

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

[sudo] password for postgres:

Sorry, try again.

My user account password doesn't work, neither does leaving it blank or typing "postgres". I tried clean reinstall of postgres a few times, just in case I missed anything.

How do I find this password?

I thought maybe I don't need this password, because typing the command from above without "sudo" seems to work (it asks me for my user account password then), but then again, when I type passwd to actually set up the password, it asks me for my current password, and the fun starts all over again.

Upvotes: 0

Views: 2173

Answers (1)

GregHNZ
GregHNZ

Reputation: 8969

When I look at this:

[postgres@B8-64-F1-BE-62-20 ~]$ sudo systemctl restart postgresql

It looks like you're in the context of the postgres user.

So when that sudo command is hit, sudo is going to ask for the password for the postgres user (whether it has one or not, or possibly, because postgres user isn't in the sudoers list).

What I think you need to do is:

exit

That will "undo" the sudo su - postgres which I'm suspecting you've done earlier (because that's one of the commands in the page you linked).

Once you've done the exit it the prompt should return to starting with your normal username.

And then, when you do sudo systemctl restart postgresql it's going to prompt you for your password, and then do the thing.

Upvotes: 1

Related Questions