postgresql은 표준SQL을 지향하고 오픈소스 라이선스이다. 그래서 SQL 공부용으로 선택했다.
교재는 "모두를 위한 postgresql"을 선택했다.
모두를 위한 PostgreSQL | 정승호 - 교보문고
모두를 위한 PostgreSQL | 누구나 배울 수 있는 PostgreSQL 실전 입문서이 책에서는 PostgreSQL를 활용하여 데이터베이스를 개발할 때 기본이 되는 요소인 테이블 생성, 컬럼 변경뿐 아니라 데이터 생성,
product.kyobobook.co.kr
https://hub.docker.com/_/postgres
postgres - Official Image | Docker Hub
Note: the description for this image is longer than the Hub length limit of 25000, so has been trimmed. The full description can be found at https://github.com/docker-library/docs/tree/master/postgres/README.md. See also docker/hub-feedback#238 and d
hub.docker.com
# 이미지 다운로드(버전 변경가능)
docker pull postgres:11.22-alpine3.19
# 실행
docker run --name postgresql -e POSTGRES_PASSWORD="비밀번호" -d -p 5432:5432 postgres:11.22-alpine3.19
# 접속
docker exec -it [컨테이너명] bash
psql -U postgres
# db생성
createdb -U postgres db명
# db에 데이터 불러오기
psql -U postgres -d db명 -f 파일명
기본적으로 psql로 접속하기 위해서는 -h {호스트명} -p {포트 번호} -U {사용자명} -d {데이터베이스명}이 필요한데 postgresql을 설치하게되면 postgres라는 유저와 postgres라는 데이터베이스가 기본적으로 저장되어 있고, 로컨 열결에 대한 인증이 "trust"로 되어 있어 psql -U postgres만으로 접속이 가능하다.
"trsut" 인증에 대한 설정은 cat /var/lib/postgresql/data/pg_hba.conf 여기서 확인가능.
'SQL' 카테고리의 다른 글
SQL UPDATE (0) | 2025.01.16 |
---|---|
SQL WHERE (0) | 2025.01.16 |
SQL 데이터 (1) | 2025.01.15 |
SQL 테이블 (1) | 2025.01.15 |
SQL 데이터베이스 (0) | 2025.01.15 |