So to change the password of postgres run this command in terminal as shown in the picture below.
This will open the file pg_hba.conf... now try to find this line as shown in the pic below
And change the peer at the last to trust and save it!
After doing this restart the postgresql server by typing the command "sudo service postgresql restart"
after that login as postgres user and run the following command to change the password as shown in the picture below!
Press Enter and that's it your password is changed ... now just go back to the pg_hba.conf file and undo the change i.e. change the trust to peer that's it!
****************************EDIT --- june 16 - 2016 *****************************
I found one more way to change postgres user password in postgresql
Just enter the following command and this will log you in as postgres user so now you can acess the psql.
After this enter the psql by simply typing psql in terminal like this.
Now just enter the command \password postgres as in the image below
and voila ... we changed the postgres password. That's it :D
This will open the file pg_hba.conf... now try to find this line as shown in the pic below
And change the peer at the last to trust and save it!
After doing this restart the postgresql server by typing the command "sudo service postgresql restart"
after that login as postgres user and run the following command to change the password as shown in the picture below!
Press Enter and that's it your password is changed ... now just go back to the pg_hba.conf file and undo the change i.e. change the trust to peer that's it!
****************************EDIT --- june 16 - 2016 *****************************
I found one more way to change postgres user password in postgresql
Just enter the following command and this will log you in as postgres user so now you can acess the psql.
After this enter the psql by simply typing psql in terminal like this.
Now just enter the command \password postgres as in the image below
and voila ... we changed the postgres password. That's it :D
This comment has been removed by the author.
ReplyDelete