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

问题描述 投票:0回答:8

我使用自制程序安装了 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/

但我还是找不到。

macos postgresql homebrew
8个回答
161
投票

默认情况下,在英特尔 Mac 上,自制软件会将所有内容放入

/usr/local

所以 postgresql conf 文件将是

/usr/local/var/postgres/

如果您使用的是 M1 Mac,brew 将使用类似

/opt/homebrew/var/postgres/pg_hba.conf

的路径

32
投票

如果您可以以超级用户身份连接到 Pg(通常是

postgres
),只需
SHOW hba_file;
即可查看其位置。

否则你必须了解 PostgreSQL 是如何启动来定位其数据目录的。


13
投票

最坏的情况,你可以搜索一下:

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

12
投票

无论您的操作系统是什么,您始终可以使用

psql
实用程序、DBeaver 或任何其他客户端工具,并键入 SQL
show
命令来查看任何运行时设置的值。

例如,在我的 BigSur OSX 系统上,我使用 EDB 安装程序安装了 PostgreSQL v13,这些是使用

postgresql.conf
实用程序的
pg_hba.conf
psql
文件的位置:

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

8
投票

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

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

/opt/homebrew/var/postgres/pg_hba.conf  

6
投票

可以使用 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
投票

在 MacOS Catalina 中位于文件夹下:

 ./Library/PostgreSQL/{postgres_version}/share/postgresql/

1
投票

了解 postgresql.conf 位置的另一个解决方案是启动 psql 并输入 \显示所有 然后搜索“config_file”的值。 对于我的 docker 配置,这将是 /var/lib/postgresql/data/postgresql.conf 然后我可以连接到 Docker docker exec -it postgres bash -c “导出 TERM=xterm-256color ; bash” 并查看其内容 猫 /var/lib/postgresql/data/postgresql.conf

© www.soinside.com 2019 - 2024. All rights reserved.