Tom 234

Posted on 16th June 2024|54 views


Change Postgres Password Ubuntu

How to reset password on Ubuntu of PostgreSQL?

1 answers
Surya kumar

Posted on 16th June 2024| views

Due to the Host-based authentication file of Ubuntu, User can log in and do all the activities on the database due mentioned in pg_hba.conf.

By using the host-based authentication file as we have:

# Database administrative login by Unix domain socket

local        all        postgres        peer

By using the peer method in the last column means that if we run psql on localhost and using UNIX domain to invoke username and login into the database.

As we generally use sudo to run SQL:

sudo -u postgres psql

Now user can issue the SQL command once he is inside the psql:

ALTER USER user_name PASSWORD 'new_password';

Now by the above command, we can reset the new password and then by restarting it or using reload pg_ctl

Then you can log in using the new password.


Write your answer


Get a Live FREE Demo

  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos
Course *
Email *
Phone Number