On Thu, 24 May 2018 23:34:23 -0700, ajat.prabha.leo wrote:
I'm an undergrad student and very new to postgresql. I have a question
to which I haven't been able to find an answer yet.
I installed postgresql and ran the command `psql -U postgres` and as
expected it failed because the role doesn't exist.
But when I tried to run `psql postgres`, it worked! My question is why
is this command working? I've not been able to find this command
anywhere in the documentation.
Now, I also created the role postgres and both commands are working.
Note: when I run `psql postgres` the logged-in user is the superuser to
OS. I'm doing this on High Sierra.
It must be that your installation process named the default superuser differently when it ran "initdb" to create the cluster.
You can use this query to find the name of the default superuser:
SELECT usename FROM pg_user WHERE usesysid = 10;
Your attempt with "psql postgres" succeeded because the default superuser happened to have the same name as your operating system user, and that's
the default that psql uses if you don't specify the -U option.
You can rename a user with
ALTER USER ... RENAME TO ...;
But you shouldn't forget that renaming a user clears the password, so you
have to set it again with \password.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)