'Postgresql: How to find pg_hba.conf file using Mac OS X

Hi I am having trouble with postgres. I don't remember my postgres password and don't know how to change the password. I'm guessing I should change the md5 password settings I set a month ago, but I don't know how to find the file and open it using my terminal. Can someone help?



Solution 1:[1]

If you can connect, use SHOW hba_file;.

If you cannot connect, you need to locate the data directory. That'll be shown as the -D argument to the postgres or pg_ctl command that starts PostgreSQL, so you can generally find it with ps -ef | grep postgres.

Solution 2:[2]

For macOS 12, you can open the file using nano in your terminal. Example below is if Postgres 12 is installed.

`nano /Library/PostgreSQL/12/data/pg_hba.conf`

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Craig Ringer
Solution 2 toking