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

PostgreSQL .conf文件在哪里?


当前回答

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

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

Select * from pg_settings where name='config_file'

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

其他回答

2022-4-25更新:

地点:/ Library / PostgreSQL / 14 /数据/ postgresql.conf

系统:MacOS Monterey

只是给那些正在寻找这条道路的人……

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

/var/lib/pgsql/9.4/data

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

对于CentOS 6和7以及postgresql 9.2(以及以下版本,我想可能也包括Fedora和Redhat):

/ var / lib / pgsql数据

对于CentOS 6和7 postgresql 9.3或9.4(以及以上版本,我想):

/var/lib/pgsql/9.3/data
/var/lib/pgsql/9.4/data

对于Ubuntu 14和postgresql 9.3:

/etc/postgresql/9.3/main/postgresql.conf

The 30-07-2019

在Windows 10 pro中:

C:\Program Files\PostgreSQL\11\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 /]#