본문 바로가기

Database/Postgresql

윈도우환경에서 Postgresql Command Line Tools(psql,pg_dump) 설치하기

728x90
반응형

 

개발PC에서 pg_dump로 Postgresql DB DDL 또는 데이터를 백업하거나 psql 로 접속해서 테이블 속성을 보고 싶을 경우가 생길것이다.

하지만 Postgresql Command Line Tools 설치파일이 따로 존재하지 않는다.

Command Line Tools만 설치할 수 있는 방법은 Postgresql 서버 설치파일을 다운받고 컴포넌트 선택화면에서  Command Line Tools를 선택하면 된다.

설치환경

  • Widnow 10 Pro
  • Postgresql Command Line Tools - 14.1
  • Postgresql Server - 13.1

 

https://www.enterprisedb.com/downloads/postgres-postgresql-downloads 접속하여 Windows x86-64, Postgresql 14.1 버전을 다운로드하자.

 

다운로드 받은 postgresql-14.1-1-windows-x64.exe 파일을 클릭하여 설치하자.

 

Command Line Tools 만 선택

 

Next

 

 

 

Finish를 클릭하면 설치가 완료된다.

 

C:\Program Files\PostgreSQL\14\bin\ 폴더를 확인해 보면 제일 많이 사용하는 psql.exe, pg_dump.exe 파일을 확인할 수 있을 것이다. (그 외 많은 툴이 설치되어 있는 것을 확인할 수 있다.)

 

윈도우 PATH를 등록하면 모든 폴더에서 명령어를 실행할 수 있다.

psql 명령어로 Postgresql DB를 접속해서 SQL 및 테이블속성(\d) 명령어를 실행하여 보자.

C:\Users\developer>psql -h 192.168.2.165 -p 5432 -U postgres -W
Password:
psql (14.1, server 13.1)
Type "help" for help.

postgres=# select current_database(), inet_server_addr(), inet_client_addr();
 current_database | inet_server_addr | inet_client_addr
------------------+------------------+------------------
 postgres         | 192.168.2.165    | 192.168.0.17
(1 row)


postgres=# \d public.dummy_table
                              Table "public.dummy_table"
  Column   |              Type              | Collation | Nullable |      Default
-----------+--------------------------------+-----------+----------+-------------------
 no        | integer                        |           | not null |
 title     | character varying(300)         |           | not null |
 content   | text                           |           |          |
 create_dt | timestamp(0) without time zone |           | not null | CURRENT_TIMESTAMP
 update_dt | timestamp(0) without time zone |           |          |
Indexes:
    "dummy_table_pkey" PRIMARY KEY, btree (no)


postgres=#

 

728x90
반응형