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

PostgreSQL .conf文件在哪里?


当前回答

Ubuntu 13.04使用软件中心安装:

我的位置是:

/etc/postgresql/9.1/main/postgresql.conf

其他回答

nantha=# SHOW config_file;

config_file

/var/lib/postgresql/data/postgresql.conf (1 行)

nantha=# SHOW hba_file;

hba_file

/var/lib/postgresql/data/pg_hba.conf (1 行)

要获得pg_hba.conf文件的位置,还可以像这样查询数据库

SHOW hba_file;

你应该买

            hba_file             
---------------------------------
 /var/lib/pgsql/data/pg_hba.conf
(1 row)

如果你在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 "中

Ubuntu 13.04使用软件中心安装:

我的位置是:

/etc/postgresql/9.1/main/postgresql.conf

如果您遵循亚马逊发布的在AWS上安装Postgresql的白皮书,其中包括在挂载在独立EBS卷上的文件系统上创建/data/目录,那么您的Postgresql .conf文件位于/data/

从中我得出结论,文件是在初始化数据目录期间创建的,并驻留在数据目录的根目录中。对于默认安装,这似乎是/var/lib/pgsql/data,但如果您移动了数据目录则不是