
DataGrip은 개발자를 위한 데이터베이스 관리 환경으로 데이터베이스를 쿼리, 생성 및 관리하도록 설계되었습니다. 데이터베이스는 로컬, 서버 또는 클라우드에서 작동할 수 있습니다.
[ PostgreSQL의 구조 ]
- PostgreSQL은 클라이언트/서버 모델을 사용한다. 서버는 데이터베이스 파일들을 관리하며, 클라이언트 애플리케이션으로부터 들어오는 연결을 수용하고, 클라이언트를 대신하여 데이터베이스 액션을 수행한다. 서버는 다중 클라이언트 연결을 처리할 수 있는데, 서버는 클라이언트의 연결 요청이 오면 각 커넥션에 대해 새로운 프로세스를 fork한다. 그리고 클라이언트는 기존 서버와의 간섭 없이 새로 생성된 서버 프로세스와 통신하게 된다.
출처: https://mangkyu.tistory.com/71 [MangKyu's Diary:티스토리]
그래서, 배포용 데이터베이스와 테스트용 데이터베이스를 분리도 가능함. => 이것도 현재 분리해주고 datagrip에서 postgreSQL 연결된 환경에서 test connection까지는 성공했음. 근데, pycharm 환경에서 테스트 환경 서버 연결 테스트 코드 실행 시 오류 발생해서 해결 필요함.
출처: https://velog.io/@moongyu1/PostgreSQL-local-database-with-DataGrip
Test Connection 날려보면, 연결이 성공되어야한다.
하지만, PostgreSQL 서버가 실행 중이지 않다는 에러 발생
Connection to localhost:5432 refused.
Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
확인 사항:
1-1) 작업 관리자에서 PostgreSQL Server가 실행 중인지 확인하기 아니면
1-2) services.msc에서 아래의 사진과 같이 실행 중인지 확인하기

1-3) cmd 창에서 아래의 명령어로 실행 확인하기
netstat -an | findstr 5432
=> 시도해보니 리스트에서 실행 중이지 아니였고 명령어 입력 시 출력되는 게 없었음
where psql # PostgreSQL 설치 유무 확인C:\Program Files\PostgreSQL\16\bin\psql.exepg_ctl 존재 여부 확인
where pg_ctl
cd "C:\Program Files\PostgreSQL\16\data"C:\Program Files\PostgreSQL\16\data>pg_ctl start -D "C:\Program Files\PostgreSQL\16\data"# 서비스 실행됨
waiting for server to start.... done
server startedpsql -U postgres -> psql (16.9)postgres=#로그 파일 확인: postgresql.conf 안에서 로그 경로를 확인하기
C:\Program Files\PostgreSQL\16\data\pg_log\
FATAL: lock file "postmaster.pid" already existscould not bind to port 5432포트 확인 (충돌 여부 확인)
netstat -ano | findstr 5432
tasklist | findstr <PID>
taskkill /PID <PID> /Fpg_ctl start로 수동 실행하기보다 자동 시작 설정을 해두기로...pg_ctl register -N "PostgreSQL16" -D "C:\Program Files\PostgreSQL\16\data"
service.msc에 등록되어서 부팅 시 자동 실행 가능함.참고 자료:
https://www.commandprompt.com/education/how-to-start-stop-or-restart-the-postgresql-server/