Re: postgres 12 password failure port 5433 - Mailing list pgsql-novice

From Zahid Rahman
Subject Re: postgres 12 password failure port 5433
Date
Msg-id CAPGSW3R0pZ=5y+msHWQumqM5bsdd_Ppyr_D5fu-baEvF6mFkaQ@mail.gmail.com
Whole thread Raw
In response to postgres 12 password failure port 5433  (Zahid Rahman <zahidr1000@gmail.com>)
List pgsql-novice
Programmatically:
LOG:
Opening database ....
time taken miiliseconds 257
closed database successfully

     try {
           System.out.println("Opening database ....");
           Start = System.currentTimeMillis();
       Connection conn = null;
           Class.forName("org.postgresql.Driver");
           conn = DriverManager
           .getConnection("jdbc:postgresql://localhost:5433/events",
           "postgres","sunrise");
           conn.close();



On Sun, 15 Dec 2019 at 16:40, Efrain Dector <admin@motumweb.com> wrote:
For local connections you have md5 You need put a password, if You can't put a password for local (127.0.0.1) You need put trust un pg_hba.conf and reload dile


host    all             all             127.0.0.1/32            md5 <--- change


El dom., 15 de dic. de 2019 10:24 a. m., Zahid Rahman <zahidr1000@gmail.com> escribió:
programmatically :

 try {
           System.out.println("Opening database ....");
           Start = System.currentTimeMillis();
           Connection conn = null;
           Class.forName("org.postgresql.Driver");
           conn = DriverManager
           .getConnection("jdbc:postgresql://localhost:5433/events",
           "postgres", "postgres");
           conn.close();
       
     } catch (Exception e) {

Opening database ....
org.postgresql.util.PSQLException: FATAL: password authentication failed for user "postgres"
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:520)
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:141)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:192)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:211)
at org.postgresql.Driver.makeConnection(Driver.java:458)
at org.postgresql.Driver.connect(Driver.java:260)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at PostgresJdbc.main(PostgresJdbc.java:15)
org.postgresql.util.PSQLException: FATAL: password authentication failed for user "postgres"


On Sun, 15 Dec 2019 at 16:10, Zahid Rahman <zahidr1000@gmail.com> wrote:
This is my ubuntu terminal prompt with root username.

kub18@UB18:~

I then types 
kub18@UB18:~$ su - postgres
Password:
postgres@UB18:~$ 
As you can see the password for user 'postgres' have been accepted and the prompt has changed.

I then typed:
postgres@UB18:~$ psql -p 5433 -h localhost
i am then prompted for postgres password

Password for user postgres:

I then typed password
the error message 
psql: error: could not connect to server: FATAL:  password authentication failed for user "postgres"
FATAL:  password authentication failed for user "postgres"

result of  sudo cat /etc/postgresql/12/main/pg_hba.conf
I have not included the comment header.

# Database administrative login by Unix domain socket
local   all             postgres                                peer

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            md5
host    replication     all             ::1/128                 md5


On Sun, 15 Dec 2019, 15:34 Arlindo Neto, <neto.acs@gmail.com> wrote:
Are you lagged in as postgres user or root? You need to be logged in as postgres in order to use psql.

Just ‘su - postgres’ as root and try to use psql again.
If it still doesn't work, send us your /etc/postgresql/11/main/pg_hba.conf 

On Sun, 15 Dec 2019 at 12:19 Zahid Rahman <zahidr1000@gmail.com> wrote:
Hi,
I have postgres 10 running on 5432 and pgadmin is connecting  ok.

 I have just installed postgres 12 on ubuntu 18.04  using apt-get install
I have the following  success messages (see below)
I have verified that I have a database running at 5433 programmatically.
The PGADMIN4 "postgres admin tool" is giving an error "UNAUTHORISED message (see below)

WHEN i TRY TO LOGIN USING  PSQL CONSOLE using command line

psql -U postgres  -p 5433 -h localhost

I get an password  error message psql: error: could not connect to server: FATAL:  password authentication failed for user "postgres"

FATAL:  password authentication failed for user "postgres"

Unauthorized

The server could not verify that you are authorized to access the URL requested. You either supplied the wrong credentials (e.g. a bad password), or your browser doesn't understand how to supply the credentials required.







Success. You can now start the database server using:
pg_ctlcluster 12 main start

Ver Cluster Port Status Owner    Data directory              Log file
12  main    5433 down   postgres /var/lib/postgresql/12/main /var/log/postgresql/postgresql-12-main.log






pgsql-novice by date:

Previous
From: Zahid Rahman
Date:
Subject: Re: postgres 12 password failure port 5433
Next
From: "Bee.Lists"
Date:
Subject: Re: Hi : Is anybody out there ?