If you use Windows and have installed Postgres 14, sometimes after installing Postgres 14 you may forget the Postgres user password and need to reset it.
We’ll walk you through the steps to reset your password and get Postgres running again.
With the following steps you will be able to reset your Postgres 14 password:
Backup: In your file explorer search for ‘ pg_hba.conf ’ back it up by copying it into a different file.
Change all methods: Open ‘ pg_hba.conf ‘ in any code editor and change all the methods of the local connections from ‘ scram-sha-256 ’ to ‘trust’ and save. After this change, you will be able to access your Postgres database server from your command line without entering a password.
From this
To this
Restart the PostgreSQL server: Go to services, search for PostgreSQL server, click on it, and in the top-left click on Restart the service.
Connect to PostgreSQL database server: Using any PostgreSQL GUIs such as Arctype you can connect to the PostgreSQL database server without entering a password. This can be done by entering the following in your command line.
psql -U postgres
Set a new password: Run the following command to set a new Postgres user password.
ALTER USER postgres WITH PASSWORD 'new_password';
Restore ‘ pg_dba.conf ‘ to its original state: change all methods from ‘ trust ’ back to ‘ scram-sha-256 ‘.
Restart the PostgreSQL server as in step3.
Connect to the PostgreSQL database using your new password with Arctype.
If the password is correct connection successful will pop up
In this tutorial, you just learned how to reset your Postgres 14 password. Check out other tutorials on how to do this as well.