Answer the question
In order to leave comments, you need to log in
How to see PostgreSQL password?
I started to study working with PostgreSQL through Python, I found this code:
import psycopg2
from psycopg2 import OperationalError
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
def create_connection(db_name, db_user, db_password, db_host, db_port):
connection = None
try:
connection = psycopg2.connect(
database=db_name,
user=db_user,
password=db_password,
host=db_host,
port=db_port,
)
print("Connection to PostgreSQL DB successful")
except OperationalError as e:
print(f"The error '{e}' occurred")
connection = create_connection("postgres", "postgres", "postgres", "127.0.0.1", "5432")
Answer the question
In order to leave comments, you need to log in
And another error with from psycopg2 import OperationalError, it simply does not find OperationalError
>>> from psycopg2 import OperationalError
>>> OperationalError
<class 'psycopg2.OperationalError'>
>>> psycopg2.__version__
'2.8.6 (dt dec pq3 ext lo64)'
The error 'FATAL: password authentication failed for user "postgres"
How can I view this password or create a new one?
ALTER ROLE postgres WITH PASSWORD '123';
or in psql Log in \password
You need to create a new user and database, assign the user as the owner of this database, and set permission in pg_hba.conf for this user to connect to the database at 127.0.0.1. You don't have to mess around with things like that.
What does it mean - Postgress was ?? How could he install himself???
Do you even know how the PC and the system works? If not, you need to start by studying this ...
Ask the password from the person who installed postgress
Look - nothing.
Change - galaxy replied.
Stop postgris, edit pg_hba.conf (essentially keeping the original one)
local all postgres trust
host all postgres 0.0.0.0/0 trust
host all all 127.0.0.0/8 trust
start postgris, then
calmly go to it at least psql with anything, and change the password
ALTER ROLE postgres WITH PASSWORD '123'; or in psql \password
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question