0

I have a project in php, there I connect to the server via ssh and my task is to change the postgresql.conf parameters. I tried this:

psql -Upgadmin -p 11935 -d postgres -c array_nulls=off
ERROR:  syntax error at or near "array_nulls"
LINE 1: array_nulls=off
        ^

or should I change the settings in postgresql.conf using sed, which command should I use?

1 Answer 1

1

Any server setting that you succeed in changing with psql will only last as long as your session. To make the change persist, you have to edit postgresql.conf, either with your favorite text editor (vim, emacs, etc.) or with a utility program (sed, awk, etc.). Everything that follows assumes that you have suitable privileges to edit postgresql.conf.

Your first job is to find it. Different Linux distributions store it in different places. In Ubuntu, it's in

/etc/postgresql/9.4/main
                ^^^

Note the version number. Different for each version of PostgreSQL, of course. If I wanted to change a setting, I'd do this after putting the file under version control.

$ sudoedit /etc/postgresql/9.4/main/postgresql.conf
[sudo] password for mike: 

Then find the setting and change it. Here's what the relevant section of postgresql.conf looks like here.

#------------------------------------------------------------------------------
# VERSION/PLATFORM COMPATIBILITY
#------------------------------------------------------------------------------

# - Previous PostgreSQL Versions -

#array_nulls = on

I'd change the setting to

array_nulls = off    # array_nulls = on

This kind of change usually requires either a reload or a restart of the PostgreSQL dbms.

Sign up to request clarification or add additional context in comments.

1 Comment

Nice answer! Thank you. And how do I change the setting through the sed? need to find the line with the parameter, remove it and insert a new one with the new value of the parameter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.