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

PostgreSQL .conf文件在哪里?


当前回答

如果您刚刚安装了它,locate可能不起作用。在这种情况下,服务应该正在运行,您可以运行

ps aux  | grep 'postgres *-D'

查看postgresql-master从哪里加载配置文件。

其他回答

因为我没有访问postgres帐户(所以不能运行SHOW config_file),我的postgres安装在Windows上,没有一个答案对我有帮助,所以我把我的文件位置分享给未来的Windows读者:

C:\Program Files\PostgreSQL\9.5\data

对于ubuntu 18/20,执行以下命令找到postgresql.conf文件:

locate postgresql.conf

如果你的linux中没有locate,那么先运行sudo apt-get install locate来安装locate。

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

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

Select * from pg_settings where name='config_file'

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

在Mac上(使用brew安装Postgres):

/usr/local/Cellar/postgresql/9.3.3>bin/postgres -D /usr/local/var/postgres/

Run

sudo updatedb

紧随其后的是

locate postgresql.conf