无法进入和更改 PostgreSQL pg_hba.conf 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11919275/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can not enter and change PostgreSQL pg_hba.conf file
提问by A_funs
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
我正在运行 OSX,我正在尝试更改 pg_hba.conf 文件中的 PostgreSQL 身份验证选项。问题是我进不去 我努力了
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.
然后用vi尝试编辑它。当我用 vi 打开文件时,vi 显示为一个新文件,只显示波浪线。如果我尝试写入该新文件,则会收到错误消息,提示我无法这样做。
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
回答by Craig Ringer
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).
猜测是,您尝试在实际不存在的目录中编辑文件,因为系统上的路径不同。如果您显示了您运行的确切命令、确切的错误消息文本、您的 PostgreSQL 版本以及您如何安装 Pg(Homebrew、EnterpriseDB 软件包等),将会有所帮助。
To edit pg_hba.conf
:
编辑pg_hba.conf
:
In psql, run:
在 psql 中,运行:
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:
并查看它报告的位置。这是您必须编辑的文件。如果进不去psql
就必须在文件系统中定位;尝试:
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:
当您找到正确的路径时,您不需要使用su
来从postgres
登录中编辑它;只需使用:
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.
如果您更喜欢使用不同的编辑器,则可以从命令行运行的任何内容都可以使用,包括大多数 GUI 编辑器。
回答by IntelliJ Amiya
You can use this way
你可以用这种方式
sudo vi /etc/postgresql/9.1/main/pg_hba.conf