How to exit from PostgreSQL command line utility: psql

前端 未结 9 1188
小鲜肉
小鲜肉 2020-12-02 03:22

What command or short key can I use to exit the PostgreSQL command line utility psql?

相关标签:
9条回答
  • 2020-12-02 04:04

    Specifically speaking, how to exit from the following status on Ubuntu 18.04.

    I put the original status as follows.

    postgres@user:~$
    

    If psql is inputed, it changes to the new status as follows.

    postgres@user:~$ psql
    
    postgres=# 
    

    If \q is inputed, please see the operation.

    postgres@user:~$ \q
    

    It changes to the original status as follows.

    postgres@user:~$
    

    The quick way is to kill the terminal. But I want to know other quit method without killing the terminal.

    Thanks,

    0 讨论(0)
  • 2020-12-02 04:06

    Try:

    • Ctrl+Z - this sends the TSTP signal (TSTP is short for “terminal stop”)
    • Ctrl+\ - this sends the QUIT signal

    For curiosity:

    • Ctrl+D - this sends the EOF character. EOF stands for "end of file". In this concrete case it exits from the psql subprogram, as the shell is waiting for user input. This should not be 'the way to go' as it is not working if:
      • any other character is entered before - try entering some white spaces and then press Ctrl+D, it's not going to exit psql.
      • if the user input is not required at all
    0 讨论(0)
  • 2020-12-02 04:07

    Ctrl+D is what I usually use to exit psql console.

    0 讨论(0)
提交回复
热议问题