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

PostgreSQL .conf文件在哪里?


当前回答

在ubuntu中,你可以找到

/etc/postgresql/11/main/pg_hba.conf

// after change restart it otherwise it won't be work

service postgresql restart

其他回答

在MacOS Mojave上,我使用brew install postgresql来安装,我在这里找到了它

/ usr / local / var / postgres - postgresql上。

我得到了这个使用下面的sql命令引用在这里的响应:

psql -U postgres -c 'SHOW config_file'

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

C:\Program Files\PostgreSQL\9.5\data

我把它定位在这里:

/var/lib/pgsql/9.6/data/postgresql.conf

或者问问你的数据库:

$ psql -U postgres -c 'SHOW config_file'

或者,如果以ubuntu用户登录:

$ sudo -u postgres psql -c 'SHOW config_file'

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