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

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 行)

其他回答

我的安装不是默认的,但你可以去Postgres目录,找到子目录\Data。

配置文件 C: \ Postgres \ \ postgresql.conf数据 C: \ Postgres \ \ pg_hba.conf数据

答案可能是您还没有初始化数据库。在安装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 /]#

对于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

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

ps aux  | grep 'postgres *-D'

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

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

C:\Program Files\PostgreSQL\9.5\data