I am running OSX, I am trying to change the PostgreSQL authentication options in the pg_hba.conf file. The problem is I can't get into it. I have tried
sudo su - postgres
Then used vi to try to edit it. When I open the file with vi, vi displays as if it's a new file, showing only tilde lines. If I try to write that new file, I get an error saying I am not able to do so.
PLease help, thanks
this is my directory:
$ sudo find / -name pg_hba.conf
Password:
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
/Library/PostgreSQL/9.1/data/pg_hba.conf
At a guess, you've tried to edit the file in a directory that doesn't actually exist, because the path on your system is different. It'd help if you showed the exact command you ran, the exact error message text, your version of PostgreSQL and how you installed Pg (Homebrew, EnterpriseDB packages, etc).
To edit pg_hba.conf
:
In psql, run:
SHOW hba_file;
and see what location it reports. That's the file you must edit. If you can't get into psql
you must locate it in the file system; try:
sudo find / -name pg_hba.conf
When you've found the correct path, you don't need to use su
to edit it from a postgres
login; just use:
sudo vim /path/to/pg_hba.conf
eg on my system:
sudo vim /var/lib/pgsql/data/pg_hba.conf
If you prefer to use a different editor, anything that can run from the command line should work, including most GUI editors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With