postgresqlsingle-user

How to exit from postgres' single-user mode?


I have entered postgres' single-user mode

$ sudo -u postgres postgres --single -D /var/db/postgresql/

PostgreSQL stand-alone backend 9.4.11
backend>

What command can I use to close single-user mode and exit back to a normal $ command prompt?


The command \q works to exit from the psql repl, but that same command does not appear to work for postgres single-user mode, i.e.

$ sudo -u postgres postgres --single -D /var/db/postgresql/

PostgreSQL stand-alone backend 9.4.11
backend> \q
ERROR:  syntax error at or near "\" at character 1
STATEMENT:  \q

backend>

Solution

  • The answer is on the Postgresql Docs page at Single-User mode. Regarding the exit it states:

    To quit the session, type EOF (Control+D, usually). If you've entered any text since the last command entry terminator, then EOF will be taken as a command entry terminator, and another EOF will be needed to exit.