我最近在Ubuntu上安装了PostgreSQL和EnterpriseDB包。我可以连接到本地数据库,但我不能配置它,因为我找不到配置文件。我搜索了整个硬盘驱动器,只找到了像pg_hba.conf.sample这样的样本

PostgreSQL .conf文件在哪里?


当前回答

打印pg_hba.conf文件位置:

su - postgres -c "psql -t -P format=unaligned -c 'show hba_file';"

打印postgresql.conf文件位置:

su - postgres -c "psql -t -P format=unaligned -c 'SHOW config_file';"

其他回答

Win7, version 10位置:

C:\Program Files\PostgreSQL\10\postgresql.conf

Fedora 20

$ cd /var/lib/pgsql/data
$ ls -ltr *.conf

-rw-------. 1 postgres postgres 20453 Jan 18 23:22 postgresql.conf
-rw-------. 1 postgres postgres  1636 Jan 18 23:22 pg_ident.conf
-rw-------. 1 postgres postgres  4476 Jan 18 23:22 pg_hba.conf

在Mac OS X上:

sudo find / -name postgresql.conf 

您可以通过下面的命令找到其他的conf文件:

sudo find / -name pg\*.conf

注:参见用法using man:

man find

Run

sudo updatedb

紧随其后的是

locate postgresql.conf

我喜欢这个线程,因为它记录了不同架构上各种postgresql.conf文件的默认位置…

但是,我也遇到了麻烦,因为我在安装时依赖这些默认值,而这些默认值已经指定了备用位置。一种方法是通过直接查询数据库来查找特定配置文件的位置:

Select * from pg_settings where name='config_file'

删除where子句以查看所有设置,这也很有启发性,因为它显示了数据目录、pg_hba.conf等的位置。