Unable to use su - postgres

I’m trying to get PostgreSQL up and running and following the guide here:

https://en.opensuse.org/SDB:PostgreSQL

In that guide it says to use the postgres user by typing in:

su - postgres

When it first asked for a password I assumed it meant my user password since that is the user account setup to use sudo but it said authentication failure.

I then tried this:

sudo -i
passwd
exit

to change the password to a known value. The passwd command completed successfully. However I still get an authentication failure when using this command.

su - postgres

I’m not entirely sure what to do to fix this problem. If anyone could offer some advice that would be great. This is a clean install with PostgreSQL installed from the standard repositories.

When you would have read

man su

you would have seen that when there is no user specified, root is the default. Thus it asks for the root password. Not your’s. Why should it? you are already loged in.

Huh?!? Where “no user” comes from?

You have to use password of user postgres. Do you actually have this user?

You are correct and I am wrong! >:). Sorry for that. :shame:

Yes, as @avidjaar says, postgres is the user where a shell process is to be started for. Thus you have to give the password of user progres. (If that user exists).

I see the postgres user listed in YaST but it doesn’t appear to be set up with a password.

Since postgres doesn’t appear to be set up as an interactive User which can login to the system, I don’t think you can use YaST to set the password.

Instead, I went “old school” at the command line and set the password that way

passwd postgres

Then, I could “su - postgres” and then execute the psql command.

HTH,
TSU