🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.databases.postgresql
3 messages
3 total messages Started by ajat.prabha.leo@ Thu, 24 May 2018 23:34
Query regarding psql command
#3376
Author: ajat.prabha.leo@
Date: Thu, 24 May 2018 23:34
8 lines
598 bytes
Hi there,
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.
Re: Query regarding psql command
#3378
Author: ajat.prabha.leo@
Date: Fri, 25 May 2018 05:25
43 bytes
Thank you Laurenz for the help 🙂
Re: Query regarding psql command
#3377
Author: Laurenz Albe
Date: Fri, 25 May 2018 11:05
31 lines
1305 bytes
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.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads