

# PostgreSQL 대화형 터미널(psql)을 사용하여 Aurora DSQL에 액세스
<a name="accessing-psql"></a>

## AWS CloudShell을 사용하여 PostgreSQL 대화형 터미널(psql)에서 Aurora DSQL에 액세스
<a name="accessing-sql-clients-psql"></a>

다음 절차에 따라에서 PostgreSQL 대화형 터미널을 사용하여 AWS CloudShell에서 Aurora DSQL에 액세스합니다. 자세한 내용은 [AWS CloudShell란 무엇인가요?](https://docs.aws.amazon.com/cloudshell/latest/userguide/welcome.html)를 참조하세요.

**AWS CloudShell을 사용하여 연결**

1. [Aurora DSQL 콘솔](https://console.aws.amazon.com/dsql)에 로그인합니다.

1. CloudShell에서 열려는 클러스터를 선택합니다. 클러스터를 아직 생성하지 않은 경우 [1단계: Aurora DSQL 단일 리전 클러스터 생성](getting-started.md#getting-started-create-cluster) 또는 [다중 리전 클러스터 생성](getting-started.md#getting-started-multi-region)의 단계를 따릅니다.

1. **쿼리 편집기로 연결**을 선택한 다음 **CloudShell로 연결**을 선택합니다.

1. admin으로 연결할지, 아니면 [사용자 지정 데이터베이스 역할](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/authentication-authorization.html#authentication-authorization-iam-role-connect)로 연결할지를 선택합니다.

1. **CloudShell에서 시작**을 선택하고 다음 CloudShell 대화 상자에서 **실행**을 선택합니다.

## 로컬 CLI를 사용하여 PostgreSQL 대화형 터미널(psql)을 사용하여 Aurora DSQL에 액세스
<a name="accessing-sql-clients-psql-local"></a>

터미널 기반 프런트 엔드에서 PostgreSQL 유틸리티인 `psql`을 사용하여 쿼리에 대화식으로 입력하고, PostgreSQL에 발급하고, 쿼리 결과를 볼 수 있습니다.

**참고**  
쿼리 응답 시간을 개선하려면 PostgreSQL 버전 17 클라이언트를 사용합니다. 다른 환경에서 CLI를 사용하는 경우 Python 버전 3.8\$1 및 psql 버전 14\$1를 수동으로 설정해야 합니다.

[PostgreSQL Downloads](https://www.postgresql.org/download/) 페이지에서 운영 체제의 설치 프로그램을 다운로드합니다. `psql`에 대한 자세한 내용은 *PostgreSQL* 웹 사이트의 [PostgreSQL 클라이언트 애플리케이션](https://www.postgresql.org/docs/current/app-psql.htm)을 참조하세요.

AWS CLI가 이미 설치되어 있는 경우 다음 예시를 사용하여 클러스터에 연결합니다.

```
# Aurora DSQL requires a valid IAM token as the password when connecting.  
# Aurora DSQL provides tools for this and here we're using Python.  
export PGPASSWORD=$(aws dsql generate-db-connect-admin-auth-token \
  --region us-east-1 \
  --expires-in 3600 \
  --hostname your_cluster_endpoint)  
  
# Aurora DSQL requires SSL and will reject your connection without it.  
export PGSSLMODE=require  
  
# Connect with psql, which automatically uses the values set in PGPASSWORD and PGSSLMODE.  
# Quiet mode suppresses unnecessary warnings and chatty responses but still outputs errors.  
psql --quiet \
  --username admin \
  --dbname postgres \
  --host your_cluster_endpoint
```