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

Lov*_*eow 43 postgresql macos homebrew

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

我跟着这个:

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

还有这个

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

但我还是找不到它.

Doo*_*oon 94

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

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

  • 我在我的主目录中,当我执行 cd /usr/local/var/postgres/ 时,它说目录不存在 (5认同)

Cra*_*ger 15

如果您可以作为超级用户(通常postgres)连接到Pg,只需SHOW hba_file;查看其位置即可.

否则你必须找出PostgreSQL如何开始定位其数据目录.


cot*_*ros 12

无论您的操作系统是什么,您始终可以使用该psql实用程序、DBeaver 或任何其他客户端工具,并键入 SQLshow命令来查看任何运行时设置的值。

例如,在我的 BigSur OSX 系统上,我使用 EDB 安装程序安装了 PostgreSQL v13,这些是使用该实用程序的位置postgresql.confpg_hba.conf文件psql

psql -U postgres -c 'show config_file'
Password for user postgres: 
                 config_file                 
---------------------------------------------
 /Library/PostgreSQL/13/data/postgresql.conf
(1 row)
Run Code Online (Sandbox Code Playgroud)
psql -U postgres -c 'show hba_file'
Password for user postgres: 
                hba_file                 
-----------------------------------------
 /Library/PostgreSQL/13/data/pg_hba.conf
(1 row)
Run Code Online (Sandbox Code Playgroud)


小智 8

这可能是查找 postgresql.conf/pg_hba.conf 文件的可能位置

/opt/homebrew/var/postgres/postgresql.conf  

/opt/homebrew/var/postgres/pg_hba.conf  
Run Code Online (Sandbox Code Playgroud)


A. *_*aum 7

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

find / -type f -name pg_hba.conf 2> /dev/null
Run Code Online (Sandbox Code Playgroud)

  • 这终于解决了我的问题 (2认同)

JMG*_*JMG 5

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

  • 编辑 postgresql.conf 文件:选择Tools> Server Configuration>postgresql.conf
  • 要编辑pg_hba.conf文件:选择Tools> Server Configuration>pg_hba.conf

  • 为了使该选项在菜单中处于活动状态,我需要连接到相关服务器,然后单击“数据库”项。 (3认同)