Thread: [ADMIN] New to postgreSQL

[ADMIN] New to postgreSQL

From
Ramesh
Date:
HI all

Im new to postgres.

I tried to create user with the command createuser from outside the psql client.  But got the below error.  

Based on tutorial, I could see the createuser <<username>> gets created, but while login it will throw error.  My case is like below.


[postgres@localhost ~]$ createuser mytest
Password:
createuser: could not connect to database postgres: FATAL:  password authentication failed for user "postgres"

Re: [ADMIN] New to postgreSQL

From
SEKA Bruno-Emmanuel
Date:

On Mon, Sep 4, 2017 at 2:11 PM, Ramesh <ramesh4f@gmail.com> wrote:
HI all

Im new to postgres.

I tried to create user with the command createuser from outside the psql client.  But got the below error.  

Based on tutorial, I could see the createuser <<username>> gets created, but while login it will throw error.  My case is like below.


[postgres@localhost ~]$ createuser mytest
Password:
createuser: could not connect to database postgres: FATAL:  password authentication failed for user "postgres"

Re: [ADMIN] New to postgreSQL

From
tirveni yadav
Date:
On Mon, Sep 4, 2017 at 7:41 PM, Ramesh <ramesh4f@gmail.com> wrote:
> HI all
>
> Im new to postgres.
>
> I tried to create user with the command createuser from outside the psql
> client.  But got the below error.
>
> Based on tutorial, I could see the createuser <<username>> gets created, but
> while login it will throw error.  My case is like below.
>
>
> [postgres@localhost ~]$ createuser mytest
> Password:
> createuser: could not connect to database postgres: FATAL:  password
> authentication failed for user "postgres"

This could be due to enabling md5 authentication for user postgres.
And password not yet set up for the user postgres.

Check pg_hba.conf.



--
Regards,

Tirveni Yadav
www.udyansh.org
www.bael.io

What is this Universe ? From what it arises ? Into what does it go?
In freedom it arises, In freedom it rests and into freedom it melts away.
Upanishads.


Re: [ADMIN] New to postgreSQL

From
Tom Lane
Date:
tirveni yadav <yadav.tirveni@gmail.com> writes:
> On Mon, Sep 4, 2017 at 7:41 PM, Ramesh <ramesh4f@gmail.com> wrote:
>> [postgres@localhost ~]$ createuser mytest
>> Password:
>> createuser: could not connect to database postgres: FATAL:  password
>> authentication failed for user "postgres"

> This could be due to enabling md5 authentication for user postgres.
> And password not yet set up for the user postgres.

On most Linux distros, the default setup is that the postgres database
user has no password --- if it did, everybody and his brother would try
that password first if they wanted to break into a database :-(.
Rather, it's typically set up so that if you are logged in as the
operating system's postgres user, as Ramesh seems to be, it will let
you in automatically based on peer authentication.  So it's not clear
why that's not working.  Looking at the pg_hba.conf file to see what
the actual authentication setup is would be a good thing.

One idea is that there's a PGHOST environment variable setting that
is affecting how createuser thinks it should connect.  Peer auth
only works when you come in through a Unix socket.

            regards, tom lane


Re: [ADMIN] New to postgreSQL

From
Siva Kandasamy
Date:
Something wrong on making default connection to your server. I would suggest try to connect default database as postgres user using psql; which will let you know if there is connection problem. Once you resolved 'default' connection problem, 'createuser' will work fine. 

For starters try 'psql -U postgres'. 


All the best!!

Siva

On Mon, Sep 4, 2017 at 12:40 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
tirveni yadav <yadav.tirveni@gmail.com> writes:
> On Mon, Sep 4, 2017 at 7:41 PM, Ramesh <ramesh4f@gmail.com> wrote:
>> [postgres@localhost ~]$ createuser mytest
>> Password:
>> createuser: could not connect to database postgres: FATAL:  password
>> authentication failed for user "postgres"

> This could be due to enabling md5 authentication for user postgres.
> And password not yet set up for the user postgres.

On most Linux distros, the default setup is that the postgres database
user has no password --- if it did, everybody and his brother would try
that password first if they wanted to break into a database :-(.
Rather, it's typically set up so that if you are logged in as the
operating system's postgres user, as Ramesh seems to be, it will let
you in automatically based on peer authentication.  So it's not clear
why that's not working.  Looking at the pg_hba.conf file to see what
the actual authentication setup is would be a good thing.

One idea is that there's a PGHOST environment variable setting that
is affecting how createuser thinks it should connect.  Peer auth
only works when you come in through a Unix socket.

                        regards, tom lane


--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



--
------------------------------------------
Sivakumar P Kandasamy

Software Engineer
Dartmouth College (dartmouth.edu)
------------------------------------------