在 OS X 上找不到 pg_hba.conf 和 postgreql.conf 文件?
Cannot find pg_hba.conf and postgreql.conf file on OS X?
我使用自制软件安装了 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/
可是我还是找不到。
默认情况下,在英特尔 Macs 上,自制程序将所有内容放入 /usr/local
因此 postgresql conf 文件将是 /usr/local/var/postgres/
如果您使用的是 M1 Mac,brew 将使用类似 /opt/homebrew/var/postgres/pg_hba.conf
的路径
最坏的情况,你可以搜索一下:
find / -type f -name pg_hba.conf 2> /dev/null
可以使用 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
如果您可以以超级用户身份连接到 Pg(通常 postgres
),只需 SHOW hba_file;
即可查看其位置。
否则你必须找出 PostgreSQL 是如何启动来定位它的数据目录的。
另一种了解 postgresql.conf 位置的解决方案是启动 psql 并键入
\显示所有
然后搜索'config_file'的值。
对于我的 docker 配置,这将是 /var/lib/postgresql/data/postgresql.conf
然后我可以连接到 Docker
docker exec -it postgres bash -c "export TERM=xterm-256color ; bash"
并查看其内容
cat /var/lib/postgresql/data/postgresql.conf
MacOS Catalina 在文件夹下:
./Library/PostgreSQL/{postgres_version}/share/postgresql/
这可能是找到 postgresql.conf/pg_hba.conf 文件的可能位置
/opt/homebrew/var/postgres/postgresql.conf
/opt/homebrew/var/postgres/pg_hba.conf
无论您的 OS 是什么,您始终可以使用 psql
实用程序、DBeaver 或任何其他客户端工具,键入 SQL show
命令以查看任何 run-time 设置的值。
例如,在我的 BigSur OSX 系统上,我使用 EDB 安装程序安装了 PostgreSQL v13,这些是 postgresql.conf
和 [=15= 的位置] 文件使用 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)
我使用自制软件安装了 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/
可是我还是找不到。
默认情况下,在英特尔 Macs 上,自制程序将所有内容放入 /usr/local
因此 postgresql conf 文件将是 /usr/local/var/postgres/
如果您使用的是 M1 Mac,brew 将使用类似 /opt/homebrew/var/postgres/pg_hba.conf
最坏的情况,你可以搜索一下:
find / -type f -name pg_hba.conf 2> /dev/null
可以使用 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
如果您可以以超级用户身份连接到 Pg(通常 postgres
),只需 SHOW hba_file;
即可查看其位置。
否则你必须找出 PostgreSQL 是如何启动来定位它的数据目录的。
另一种了解 postgresql.conf 位置的解决方案是启动 psql 并键入 \显示所有 然后搜索'config_file'的值。 对于我的 docker 配置,这将是 /var/lib/postgresql/data/postgresql.conf 然后我可以连接到 Docker docker exec -it postgres bash -c "export TERM=xterm-256color ; bash" 并查看其内容 cat /var/lib/postgresql/data/postgresql.conf
MacOS Catalina 在文件夹下:
./Library/PostgreSQL/{postgres_version}/share/postgresql/
这可能是找到 postgresql.conf/pg_hba.conf 文件的可能位置
/opt/homebrew/var/postgres/postgresql.conf
/opt/homebrew/var/postgres/pg_hba.conf
无论您的 OS 是什么,您始终可以使用 psql
实用程序、DBeaver 或任何其他客户端工具,键入 SQL show
命令以查看任何 run-time 设置的值。
例如,在我的 BigSur OSX 系统上,我使用 EDB 安装程序安装了 PostgreSQL v13,这些是 postgresql.conf
和 [=15= 的位置] 文件使用 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)