DEV/Backend

PostgreSQL 터미널에서 접속하는 방법

Beomsu Koh 2023. 4. 5.

PostgreSQL 접속하는 방법

터미널이나 명령 프롬프트를 열고 다음과 같이 입력합니다.

  • psql -U [username] -h [hostname] -p [port] -d [database_name]
    • Ex. psql -U berom -d postgres
      예를 들어, 사용자 이름이 postgres, 호스트 이름이 localhost, 포트 번호가 5432, 데이터베이스 이름이 mydb인 경우 다음과 같이 입력합니다.
  • psql -U postgres -h localhost -p 5432 -d mydb
    비밀번호를 입력하라는 메시지가 나타나면 입력하고 Enter를 누릅니다.

댓글