리눅스 postgresql 접속 방법 및 옵션

2020. 11. 18. 16:27· Back-End/리눅스
목차
  1. postgresql 버전 확인 명령어
  2. psql 접속 방법
  3. psql 옵션 확인 명령어
반응형
SMALL
SMALL

postgresql 버전 확인 명령어


psql -V

login as: root
root@ ~'s password:
Last login: Wed Nov 18 16:04:22 2020 from ~
[root@ ~ ]#
[root@ ~ ]# psql -V
psql (PostgreSQL) 9.6.14
[root@ ~ ]#

 

 

psql 접속 방법


psql -U postgres

[root@ ~ ]# psql -U postgres
Password for user postgres:
psql (9.6.14)
Type "help" for help.

postgres=# \list
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 test      | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =T/postgres          +
           |          |          |             |             | postgres=CTc/postgres+
           |          |          |             |             | test=CTc/postgres
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
(4 rows)

postgres=#

만약 test 라는 DB에 접속을 하고 싶다면 -d 옵션을 붙여주면 된다.

psql -U postgres -d test

 

 

 

 

psql 옵션 확인 명령어


psql -?

[root@ ~ ]# psql -?
psql is the PostgreSQL interactive terminal.

Usage:
  psql [OPTION]... [DBNAME [USERNAME]]

General options:
  -c, --command=COMMAND    run only single command (SQL or internal) and exit
  -d, --dbname=DBNAME      database name to connect to (default: "root")
  -f, --file=FILENAME      execute commands from file, then exit
  -l, --list               list available databases, then exit
  -v, --set=, --variable=NAME=VALUE
                           set psql variable NAME to VALUE
                           (e.g., -v ON_ERROR_STOP=1)
  -V, --version            output version information, then exit
  -X, --no-psqlrc          do not read startup file (~/.psqlrc)
  -1 ("one"), --single-transaction
                           execute as a single transaction (if non-interactive)
  -?, --help[=options]     show this help, then exit
      --help=commands      list backslash commands, then exit
      --help=variables     list special variables, then exit

Input and output options:
  -a, --echo-all           echo all input from script
  -b, --echo-errors        echo failed commands
  -e, --echo-queries       echo commands sent to server
  -E, --echo-hidden        display queries that internal commands generate
  -L, --log-file=FILENAME  send session log to file
  -n, --no-readline        disable enhanced command line editing (readline)
  -o, --output=FILENAME    send query results to file (or |pipe)
  -q, --quiet              run quietly (no messages, only query output)
  -s, --single-step        single-step mode (confirm each query)
  -S, --single-line        single-line mode (end of line terminates SQL command)

Output format options:
  -A, --no-align           unaligned table output mode
  -F, --field-separator=STRING
                           field separator for unaligned output (default: "|")
  -H, --html               HTML table output mode
  -P, --pset=VAR[=ARG]     set printing option VAR to ARG (see \pset command)
  -R, --record-separator=STRING
                           record separator for unaligned output (default: newline)
  -t, --tuples-only        print rows only
  -T, --table-attr=TEXT    set HTML table tag attributes (e.g., width, border)
  -x, --expanded           turn on expanded table output
  -z, --field-separator-zero
                           set field separator for unaligned output to zero byte
  -0, --record-separator-zero
                           set record separator for unaligned output to zero byte

Connection options:
  -h, --host=HOSTNAME      database server host or socket directory (default: "local socket")
  -p, --port=PORT          database server port (default: "5432")
  -U, --username=USERNAME  database user name (default: "root")
  -w, --no-password        never prompt for password
  -W, --password           force password prompt (should happen automatically)

For more information, type "\?" (for internal commands) or "\help" (for SQL
commands) from within psql, or consult the psql section in the PostgreSQL
documentation.

Report bugs to <pgsql-bugs@postgresql.org>.
[root@ ~ ]#
반응형

'Back-End > 리눅스' 카테고리의 다른 글

CentOS에서 로그인 시 bash-4-2$ 가 나올때 조치 방법  (2) 2021.12.02
[Linux] 모니터링을 위한 watch 명령어  (0) 2021.05.03
쉘 스크립트 만들기  (2) 2018.11.29
리눅스 톰캣 버전 확인방법  (0) 2017.12.08
리눅스 아파치 버전 확인방법  (0) 2017.12.08
  1. postgresql 버전 확인 명령어
  2. psql 접속 방법
  3. psql 옵션 확인 명령어
'Back-End/리눅스' 카테고리의 다른 글
  • CentOS에서 로그인 시 bash-4-2$ 가 나올때 조치 방법
  • [Linux] 모니터링을 위한 watch 명령어
  • 쉘 스크립트 만들기
  • 리눅스 톰캣 버전 확인방법
- 광속거북이 -
- 광속거북이 -
IT관련 일하면서 공부 및 일상 에 관한 내용들을 기록하기 위한 블로그 입니다.
누리IT관련 일하면서 공부 및 일상 에 관한 내용들을 기록하기 위한 블로그 입니다.
- 광속거북이 -
누리
- 광속거북이 -
전체
오늘
어제
  • 카테고리 (453) N
    • 구글문서 (4)
    • 설치방법들 (3)
    • FrameWork (73)
      • Django (6)
      • Python (32)
      • AngularJS (13)
      • spring (21)
    • Programing (61)
      • JAVA (11)
      • etc... (2)
      • 오류 해결 (29)
      • Algorithm (5)
    • Front-End (25)
      • CSS (3)
      • html (6)
      • javascript (10)
      • vueJS (5)
    • Back-End (5) N
      • 리눅스 (12)
      • PostgreSQL (14)
      • MySQL (2)
      • Shell (1)
      • docker (1)
      • GIT (1)
    • Util (9)
      • BIRT (2)
      • JMeter (3)
      • MobaXterm Personal (1)
      • ClipReport (2)
    • 이클립스 설정 (10)
      • SVN (1)
    • 업무중 기록해둘 것들... (1)
    • 영화 (8)
    • etc.. (198)
      • 여행 (25)
      • 문화생활 (3)
      • tistory (3)
      • 글, 생각 (4)
      • 먹을 곳 (29)
      • issue (4)
      • 결혼 (1)
      • 가족여행기록 (1)
      • Tip (51)
      • 강아지 (5)
      • 일기 (0)
      • 게임 (3)
      • 주식 (7)
      • 코로나19 (7)
      • 맥북 (5)
    • 비공개 (0)

블로그 메뉴

  • 홈
  • 태그
  • 미디어로그
  • 위치로그
  • 방명록

공지사항

인기 글

태그

  • tomcat
  • 삼성증권
  • 백준
  • PostgreSQL
  • 연천
  • 인텔리제이
  • 윈도우10
  • 설정
  • 제주도
  • 설치
  • 카페
  • 해지
  • IntelliJ
  • 이클립스
  • 합정
  • 리눅스
  • Java
  • 포켓몬고
  • 맛집
  • VSCode

최근 댓글

최근 글

hELLO · Designed By 정상우.v4.2.1
- 광속거북이 -
리눅스 postgresql 접속 방법 및 옵션
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.