postgresql 在 OS X 上找不到 pg_hba.conf 和 postgreql.conf 文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33015471/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 06:05:39  来源:igfitidea点击:

Cannot find pg_hba.conf and postgreql.conf file on OS X?

macospostgresqlhomebrew

提问by LoveMeow

I installed postgres using homebrew. I would like to locate he files pg_hba.conf and postgresql.conf but I cannot find them.

我使用自制软件安装了 postgres。我想找到他的文件 pg_hba.conf 和 postgresql.conf 但我找不到它们。

I followed this :

我跟着这个:

https://askubuntu.com/questions/256534/how-do-i-find-the-path-to-pg-hba-conf-from-the-shell

https://askubuntu.com/questions/256534/how-do-i-find-the-path-to-pg-hba-conf-from-the-shell

and this

和这个

http://www.kelvinwong.ca/tag/pg_hba-conf/

http://www.kelvinwong.ca/tag/pg_hba-conf/

but I still cannot find it.

但我仍然找不到它。

回答by Doon

By default homebrew puts everything in /usr/local

默认情况下,自制软件将所有内容都放入 /usr/local

So the postgresql conf files will be /usr/local/var/postgres/

所以 postgresql conf 文件将是 /usr/local/var/postgres/

回答by Craig Ringer

If you can connect to Pg as the superuser (usually postgres) simply SHOW hba_file;to see its location.

如果您可以作为超级用户(通常是postgres)连接到 Pg只是SHOW hba_file;为了查看它的位置。

Otherwise you have to find out how PostgreSQL is started to locate its data directory.

否则,您必须找出 PostgreSQL 是如何启动以定位其数据目录的。

回答by JMG

It's possible to edit those files without knowing their locations with pg admin https://dba.stackexchange.com/questions/61193/how-to-edit-postgresql-conf-with-pgadmin

可以使用 pg admin https://dba.stackexchange.com/questions/61193/how-to-edit-postgresql-conf-with-pgadmin 在不知道它们位置的情况下编辑这些文件

  • To edit the postgresql.conf file: Choose Tools> Server Configuration> postgresql.conf
  • To edit the pg_hba.conf file: Choose Tools> Server Configuration> pg_hba.conf
  • 编辑 postgresql.conf 文件:选择Tools> Server Configuration>postgresql.conf
  • 要编辑pg_hba.conf文件:选择Tools> Server Configuration>pg_hba.conf

回答by A. Scherbaum

Worst case, you can search for it:

最坏的情况,您可以搜索它:

find / -type f -name pg_hba.conf 2> /dev/null

回答by Olivier D

Another solution to know the location of postgresql.conf is to start psql and type \show all Then search for the value of 'config_file'. For my docker configuration, this will be /var/lib/postgresql/data/postgresql.conf then I can connect to Docker with docker exec -it postgres bash -c "export TERM=xterm-256color ; bash" and view its content with cat /var/lib/postgresql/data/postgresql.conf

另一个知道 postgresql.conf 位置的解决方案是启动 psql 并输入 \show all 然后搜索 'config_file' 的值。对于我的 docker 配置,这将是 /var/lib/postgresql/data/postgresql.conf 然后我可以使用 docker exec -it postgres bash -c "export TERM=xterm-256color ; bash" 连接到 Docker 并查看其内容cat /var/lib/postgresql/data/postgresql.conf