Prepare knowledge:
- The file “pg_hba.conf” control whether password or not:
Restart PostgreSQL server:
typing “services.msc” on Run and Enter key.
config password Steps:
- find the file pg_hba.conf;
- Back it up;
- place the following line
local all all trust
restart your PostgreSQL server
you can now connect as any user. Connect as the superuser postgres
>psql -p 5433 -U postgres
- Reset password ('replace my_user_name with postgres since you are resetting postgres user)
ALTER USER my_user_name with password 'my_secure_password';
ALTER USER postgres with password 'pass@2022';
Restore the old pg_hba.conf as it is very dangerous to keep around
Restart the server, in order to run with the safe pg_hba.conf.
Result:
The ConnectionString is "Host=localhost;Port=5433;Username=postgres;Password=pass@2022;Database=dvdrental;";
Dos Commands:
>cd C:\Program Files\PostgreSQL\14\bin>
>psql -p 5433 -U postgres
postgres=# ALTER USER postgres with password 'pass@2022';
It worked!
The end!
Top comments (0)