Reset Default PostgreSQL User Password

A common scenario working with Postgres is when you have forgotten your default Postgres user password. This is the password you will have entered during your Postgres installation.

This is a guide on how to reset the default Postgres user password. This should hopefully help you resolve this issue on your test Postgres environment.

Resetting the local default postgres user password includes the following steps:
– Open the Postgres pg_hba config file.
– Amend the authentication method to allow local connectivity.
– Update Postgres User password.
– Revert the change in pg_hba.config file once verified.

How to Reset Postgres User Password

1. Open your pg_hba.conf file which can be found in your data directory.
Default Path: C:\Program Files\PostgreSQL\10\Data

2. Change the method within the pg_hba.conf file as highlighted below, from md5 to trust.

Postgres pg_hba Config File

3. Restart the postgresql service.

4. Open psql in your terminal, connect and execute the ALTER USER SQL Statement as shown below.

psql ALTER DATABASE

5. Now open pgAdmin, you should be able to log back in with the ‘postgres’ user.


Comments

Leave a Reply

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

Recent Posts
Categories
Tags

Always On Availability Groups (AAG) (4) AWS (4) AWS Redshift (6) Database Admin (72) Database Backups & Recovery (14) Database Mirroring (2) Error Messages (5) Failover Cluster Instances (FCI) (1) Git Commands (6) Importing & Exporting Data (2) Linked Servers (3) Linux Administration (2) Logging & Monitoring (1) Microsoft Patching (2) MySQL (4) Postgres (6) PowerShell Scripts (2) SQL Certificates & Encryption (3) SQL Server Agent (5) SQL Server CDC (2) SQL Server Data Types (2) SQL Server Management Studio (SSMS) (16) SQL Server Networking (3) SQL Server on Linux (1) SQL Server Patching (2) SQL Server Performance Tuning (6) SQL Server Processes (SPIDs) (7) SQL Server Replication (2) SQL Server Scripts (13) SQL Server Security (4) SQL Server Storage (10) Windows Admin (21) Windows Authentication (2) Windows Automation (1) Windows Events (2) Windows Firewall (4) Windows Subsystem for Linux (WSL) (18)