728x90
https://www.postgresql.org/docs/current/postgres-user.html
1. DB driver 설치
# 설치
$ brew install postgresql
# postgreSQL 버전확인
$ postgres --version
뭘 엄청 설치해서 당황 ;_; 오래걸렸다
1-1.
# postgresql start
brew services start postgresql
# version check
postgres -V
# 최초 계정 접속
psql postgres
#db 생성
create database db명;
#user 생성
create user 아이디 with encrypted password '비밀번호';
#user에게 권한 부여
grant all privileges on database db명 to 아이디;
# postgresql stop
brew services stop postgresql
2. build.gradle
dependencies {
runtimeOnly 'org.postgresql:postgresql'
}
3. application.properties
# Postgresql
spring.datasource.url=jdbc:postgresql://localhost:port/dbName
# 기본 포트는 localhost:5432/postgres
spring.datasource.username=<username def: postgres>
spring.datasource.password=<password def: superUser의 password>
# JPA
spring.jpa.hibernate.dialect = org.hibernate.dialect.PostgreSQL10Dialect
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.format_sql = true
spring.jpa.show-sql = true
728x90
'Web > DB' 카테고리의 다른 글
[mariaDB] Spring + mariaDB 연동 (0) | 2023.04.04 |
---|---|
MySQL 데이터베이스 스키마/테이블/컬럼 네이밍 설계 규칙 (0) | 2023.03.19 |
[SQL] 정규화(Normalization) (0) | 2023.03.05 |
[Hibernate orm] 11. Fetching (0) | 2023.02.16 |
[Spring framework Data JPA] 5.1.5. Specifications (0) | 2023.02.09 |