Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to syntax check PostgreSQL config files?

Tags:

I am often editing the pg_hda.conf file and I was just wondering if there is a way to make sure that what I just wrote is correct.

So far I'm using a test server to check my changes.

Like Apache has its apache2ctl -t command, does Postgres has something similar?

like image 745
SamK Avatar asked May 02 '13 08:05

SamK


People also ask

How do I find PostgreSQL config file?

PostgreSQL configuration files are stored in the /etc/postgresql/<version>/main directory. For example, if you install PostgreSQL 12, the configuration files are stored in the /etc/postgresql/12/main directory. To configure IDENT authentication, add entries to the /etc/postgresql/12/main/pg_ident. conf file.

What is Postgres configuration file?

conf is PostgreSQL's main configuration file and the primary source of configuration parameter settings. postgresql. conf is a plain text file generated by initdb and is normally stored in the data directory. However some distributions' packages may place postgresql.

Where is PostgreSQL config file windows?

Open the PostgreSQL configuration file. The file is named postgresql. conf. By default, on RHEL 7, the file is at /var/lib/pgsql/data/, and on Windows, the file is at C:\Program Files\PostgreSQL\ version_number \data\.


1 Answers

It's bee a long time, but now check is available for pg_hba.conf file:

select pg_hba_file_rules(); 

Also, you may use pg_file_settings view to define error in postgresql.conf:

select sourcefile, name,sourceline,error from pg_file_settings where error is not null; 

example output:

postgres=# select sourcefile, name,sourceline,error from pg_file_settings where error is not null;                sourcefile               |  name  | sourceline |                error ----------------------------------------+--------+------------+--------------------------------------  /var/lib/pgsql/11/data/postgresql.conf | lalala |          1 | unrecognized configuration parameter 

here I put some bad stuff to check if it's true :)

like image 180
Mikhail Aksenov Avatar answered Sep 22 '22 16:09

Mikhail Aksenov