Posted on 29th April 2025|54 views
How to reset password on Ubuntu of PostgreSQL?
Posted on 29th April 2025| 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.