How to Change Postgresql's Postgres Password
This is how you would change your PostgreSQL user postgres password, in case you forgot it. This is done in ubuntu 12.04. 1.) Logon to you...
https://www.czetsuyatech.com/2021/07/postgresql-change-postgres-password.html
This is how you would change your PostgreSQL user postgres password, in case you forgot it. This is done in ubuntu 12.04.
1.) Logon to your postgres account in behalf of root:
2.) Go into psql
3.) Press ctrl+d and it's done.
Here's another method I learned:
1.) Open pg_hba.conf
Change: local all postgres peer
To: local all postgres trust
2.) Restart the server: sudo service postgresql restart
3.) Login and update the postgres password:
4.) Finally, allow password-based authentication on pg_hba.conf.
Change: local all postgres trust
To: local all postgres md5
I might as well share how to enable remote access to a PostgreSQL server, there are 2 files that should be modified:
1.) listen to a remote IP or all
2.) Allow client authentication
1.) Logon to your postgres account in behalf of root:
>sudo -u postgres psql template1 //enter your passwordNow you're into postgres
2.) Go into psql
>psql >alter user postgres with encrypted password <your_password>
3.) Press ctrl+d and it's done.
Here's another method I learned:
1.) Open pg_hba.conf
Change: local all postgres peer
To: local all postgres trust
2.) Restart the server: sudo service postgresql restart
3.) Login and update the postgres password:
psql -U postgres alter user postgres with password 'password';
4.) Finally, allow password-based authentication on pg_hba.conf.
Change: local all postgres trust
To: local all postgres md5
I might as well share how to enable remote access to a PostgreSQL server, there are 2 files that should be modified:
1.) listen to a remote IP or all
>sudo vi /etc/postgresql/9.1/main/postgresql.conf //change listen_addresses='localhost' to listen_addresses='*' //or specific ip listen_addresses='x.x.x.x'
2.) Allow client authentication
>sudo vi /etc/postgresql/9.1/main/pg_hba.conf //local host all all 127.0.0.1/32 trust //for ipv4 host all all x.x.x.x/24 md5
Post a Comment