我最近在Ubuntu上安装了PostgreSQL和EnterpriseDB包。我可以连接到本地数据库,但我不能配置它,因为我找不到配置文件。我搜索了整个硬盘驱动器,只找到了像pg_hba.conf.sample这样的样本
PostgreSQL .conf文件在哪里?
我最近在Ubuntu上安装了PostgreSQL和EnterpriseDB包。我可以连接到本地数据库,但我不能配置它,因为我找不到配置文件。我搜索了整个硬盘驱动器,只找到了像pg_hba.conf.sample这样的样本
PostgreSQL .conf文件在哪里?
当前回答
除了直接的答案,你可能还想看看关于Postgres配置文件位置的文档。
在大多数情况下:在$PGDATA下,通常是/var/lib/postgresql/data或类似的路径(如果使用Docker映像,至少它是默认路径)。
其他回答
在linux上的默认位置是:
cd /etc/postgresql/12/main/
12-version 根据安装版本不同,版本可能不同
如果您遵循亚马逊发布的在AWS上安装Postgresql的白皮书,其中包括在挂载在独立EBS卷上的文件系统上创建/data/目录,那么您的Postgresql .conf文件位于/data/
从中我得出结论,文件是在初始化数据目录期间创建的,并驻留在数据目录的根目录中。对于默认安装,这似乎是/var/lib/pgsql/data,但如果您移动了数据目录则不是
答案可能是您还没有初始化数据库。在安装postgres之后,但在初始化数据库之前,postgres*. .SQL文件将不存在。初始化数据库后,postgres*.将出现SQL文件。(Centos 6, Postgres 9.3演示在这里)
[root@localhost /]# yum -y install postgresql93 postgresql93-server
[root@localhost /]# ls /var/lib/pgsql/9.3/data/
[root@localhost /]#
[root@localhost /]# service postgresql-9.3 initdb
Initializing database: [ OK ]
[root@localhost /]# ls /var/lib/pgsql/9.3/data/
base pg_ident.conf pg_serial pg_subtrans pg_xlog
global pg_log pg_snapshots pg_tblspc postgresql.conf
pg_clog pg_multixact pg_stat pg_twophase
pg_hba.conf pg_notify pg_stat_tmp PG_VERSION
[root@localhost /]#
在Mac OS X上:
sudo find / -name postgresql.conf
您可以通过下面的命令找到其他的conf文件:
sudo find / -name pg\*.conf
注:参见用法using man:
man find
在MacOS Mojave上,我使用brew install postgresql来安装,我在这里找到了它
/ usr / local / var / postgres - postgresql上。
我得到了这个使用下面的sql命令引用在这里的响应:
psql -U postgres -c 'SHOW config_file'