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

Solution 1:

Another way I learned recently is to go to the terminal and type:

ps aux | grep postgres

which shows all the postgres processes running on your machine. From the list you should see one with the format ... -D .... E.G:

root            4155   0.0  0.0  2432908     68   ??  S     6May13   0:00.01 sudo su postgres -c /opt/local/lib/postgresql84/bin/postgres -D /opt/local/var/db/postgresql84/defaultdb -p 5432

the -D means directory. In the terminal, do a sudo su and then cd to that directory, and you'll find the pg_hba.conf file.

And one more way:

Go to your terminal and type: locate pg_hba.conf. There should be a few results.

Solution 2:

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.