[PostgreSQL] PostgreSQL&pgAdmin 설치 및 Spring 연결(for Mac)

PostgreSQL 설치

https://www.postgresql.org/download/macosx/ 를 통해서 PostgreSQL을 다운받습니다. 저는 16 버전(2024.08.01 기준)을 다운받았습니다.

다운받은 PostgreSQL을 설치 및 실행하고, Start 버튼을 클릭해 서버를 실행시킵니다.

 

pgAdmin 설치

https://www.pgadmin.org/download/pgadmin-4-macos/ 에서 pgAdmin4를 다운받습니다. 저는 8.10 버전(2024.08.01 기준)을 다운받았습니다.

 

pgAdmin을 실행시키고 Register -> Server 버튼을 클릭합니다.

 

General 탭에서 서버 이름을 작성해줍니다.

 

Connection 탭에서 Host name/address와 Username, Password를 작성해줍니다.

 

Save 버튼을 클릭해 서버를 생성합니다.

 

Create -> Database 버튼을 클릭합니다.

 

General 탭에서 데이터베이스 이름을 작성해줍니다.

 

Save 버튼을 클릭해 데이터베이스를 생성합니다.

 

Spring 연결

인텔리제이에서 프로젝트를 생성한 후, application.yml 파일에 아래 코드를 작성하고 서버를 실행시킵니다. 프로젝트 생성 방법은 하단 포스팅에 작성되어 있습니다.

spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/{Database 이름}
    username: {서버 생성 시 작성한 Username}
    password: {서버 생성 시 작성한 Password}
    driver-class-name: org.postgresql.Driver

 

https://jihyun-devstory.tistory.com/26

 

JWT를 이용한 로그인 구현 (1) - 프로젝트 생성

✔️ 프로젝트 생성Spring Initializer 페이지(https://start.spring.io/)에서 다음과 같이 dependency를 추가한 후 Generate 버튼을 클릭한다. 현재 새롭게 업데이트 되었지만 본인은 Spring Boot 3.2.2 버전을 사용했

jihyun-devstory.tistory.com

성공적으로 연결이 완료되면, 작성했던 엔티티가 Schemas - Tables에 등록됩니다.

 

 

아래 블로그를 참고하였습니다.

https://jhlee-developer.tistory.com/entry/PostgresSQL-PostgresSQL-%EC%84%A4%EC%B9%98-%EB%B0%A9%EB%B2%95

 

[PostgresSQL] PostgresSQL, pgAdmin 설치 (for Mac)

PostgresSQL 설치 (for Mac) Postgres.app 사이트에서 Latest Release 된 버전을 다운로드 한다. (2023-06-19 기준 - 15.3 버전) 설치 후 PostgreSQL15를 Start 해준다. PostgreSQL15 실행 (Not running → Running) pgAdmin4 설치 (for Mac

jhlee-developer.tistory.com

 

'Backend' 카테고리의 다른 글

[Back-end] 단위 테스트 작성 방법(feat.TDD)  (2) 2023.11.09
[Back-end] DTO vs VO vs Entity  (0) 2023.11.09