Я установил postgres в REDHAT 7. Затем я установил python 3.6. Я создал виртуальную среду. Также я создал таблицу в postgres. Затем я выполнил этот скрипт python и получил ошибку.
import psycopg2
conn = psycopg2.connect("dbname=postgres user=postgres host=localhost password=postgres")
Ошибка:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/data/scripts/san-automation/lib/python3.7/site-packages/psycopg2/__init__.py", line 126, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not initiate GSSAPI security context: Unspecified GSS failure. Minor code may provide more information
could not initiate GSSAPI security context: Server not found in Kerberos database
FATAL: Ident authentication failed for user "postgres"
cat /var/lib/pgsql/12/data/pg_hba.conf
# 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 trust
# IPv6 local connections:
host all all ::1/128 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 ident
host replication all ::1/128 ident