Connect with us

How to

How to Reset Forgotten Postgres Password

Published

on

How to Reset Postgres Password

Remembering a password may be a hectic task for most of us. Most of the time a situation arises to reset the password because of forgetting it. It also applies to Postgres when you forgot the current password. Postgres is basically a relational Database management system that is a freely accessible resource. Postgres originated from the University of California and it is mainly used by web, mobile, geospatial, and analytics applications as a data storage service. Since Postgres utilizes the pg_hba.conf file in the data directory for user authentication, you need to modify it to reset the password.

Table of Contents

Postgres SQL

Steps to Reset Postgres Password

[1] Initially, your Postgres file pg_hba.conf needs to be backed up. Hence copy it to another location or rename it to pg_hba.conf.bk.

[2] Change all your local connections from md5 to trust to change the pg_dba.conf file.

Reset Forgotten Postgres Password

[3] Now, you will be able to log in to the PostgreSQL database server without providing any password.

[4] Restart the PostgreSQL server on your Windows from Services or enter the following command

pg_ctl -D "C:\Program Files\PostgreSQL\12\data" restart

[5] Finally, use tools such as psql or pgAdmin to connect to the PostgreSQL database server.

[6] Now, use the below command to set a new password for the Postgres user.

ALTER USER postgres WITH PASSWORD 'new_password';

[6] Reload the pg_dba.conf file and restart the PostgreSQL database server. Now, connect to the PostgreSQL database server with your new password.

Reload the configuration file

Related Articles:

FAQ

[1] What is the password for Postgres users?

Initially, a Postgres user does not require a password for authentication. However, if you need to add a password for login, connect as a Postgres user and head over to the changing password section.

[2] What are the tools used to reset the Postgress password?

Tools such as psql or pgAdmin are used to connect to the PostgreSQL database server while resetting the Postgres password.

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *