Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I reset the postgresql 9.2 default user (usually 'postgres') password on mac os x 10.8.2?

I just installed PostgreSQL 9.2 from enterprisedb onto Mac OS X 10.8.2. I mistyped my postgres user password, so I can't connect. How do I reset the password?

like image 947
Heath Borders Avatar asked Dec 17 '12 20:12

Heath Borders


People also ask

What to do if we forgot PostgreSQL password?

If you don't remember your PostgreSQL database password, you can follow the steps below to reset it to a new value: Change the authentication method in the PostgreSQL configuration file pg_hba. conf from md5 to trust and reload the configuration. You should now be able to connect to PostgreSQL with the new password.

What is the default password for postgres user in PostgreSQL?

For most systems, the default Postgres user is postgres and a password is not required for authentication. Thus, to add a password, we must first login and connect as the postgres user.


1 Answers

Found directions:

sudo su postgres 

modify /Library/PostgreSQL/9.2/data/pg_hba.conf

-local all all   md5 +local all all   trust 

restart postgres

/Library/PostgreSQL/9.2/bin/pg_ctl restart -D /Library/PostgreSQL/9.2/data/ 

Connect to postgres:

psql 

Inside psql (\q to quit):

ALTER USER postgres WITH ENCRYPTED PASSWORD 'password'; 

modify pg_hba.conf back

+local all all   md5 -local all all   trust 

restart postgres

/Library/PostgreSQL/9.2/bin/pg_ctl restart -D /Library/PostgreSQL/9.2/data/ 
like image 92
Heath Borders Avatar answered Sep 28 '22 09:09

Heath Borders