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

PostgreSQL .conf文件在哪里?


当前回答

如果你在docker容器中有postgres,可能你正在绑定。conf文件,要找到你在docker外部使用的。conf文件,运行docker inspect postgres11或postgres容器名称或id。该命令返回一个json,查找类似于

"HostConfig": {
            "Binds": [
                "/home/my_user/postgres11/:/var/lib/postgresql/data"
            ]

如果执行SHOW config_file;结果在/var/lib/postgresql/data/postgresql.conf中,那么你就知道外面的。conf文件在/home/my_user/postgres11/postgresql.conf中,或者结果在属性" bindings "中

其他回答

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

C:\Program Files\PostgreSQL\9.5\data

在Mac OS X上:

sudo find / -name postgresql.conf 

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

sudo find / -name pg\*.conf

注:参见用法using man:

man find

The 30-07-2019

在Windows 10 pro中:

C:\Program Files\PostgreSQL\11\data

在CentOS 7和PostgreSQL 9.4中,它在以下目录中:

/var/lib/pgsql/9.4/data

当我以root用户登录时,我可以看到它。

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

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

Select * from pg_settings where name='config_file'

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