Resetting the root postgres password for PostgreSQL
NOTE:
In step 2 and 5 you will most likely not be using “ident” but rather “password” or “md5” or "peer".
NOTE:
all actions need to be performed as root
1. Shut down PostgreSQL
#service postgresql stop
2. Reset the authentication mechanism (assuming defaults are already being used)
Edit the /etc/postgresql/X.Y/main/pg_hba.conf file
#pico /etc/postgresql/X.Y/main/pg_hba.conf
Navigate down to the line that says
local all all ident [ or peer, ...]
Edit it to
local all postgres trust
And now save the file.
3. Start PostgreSQL
#service postgresql start
4. Log in and change the password
#su - postgres
$psql -d postgres -U postgres [DB postgres could be template1 or something else]
[check also /etc/phppgadmin/config.inc.php ]
>alter user postgres with password 'new_password';
>\q [to quit client]
$exit [turn back to root shell]
5. Reverse the actions you did in step 2
Edit the /etc/postgresql/X.Y/main/pg_hba.conf file
#pico /etc/postgresql/X.Y/main/pg_hba.conf
Navigate down to the line that says
local all postgres trust
Edit it to
local all all ident [ or peer, ...]
And now save the file.
6. Start PostgreSQL
# service postgresql start
Success!