M2칩 postgresql 설치 방법(brew 이용)

정병웅·2023년 4월 19일
0

DataBase

목록 보기
2/2

사전에 brew가 설치 되어 있어야하기 때문에 아래의 경로에서 brew를 깔쌈하게 설치하고 오면 된다!
https://velog.io/@jbw03456/%EB%A7%A5%EB%B6%81-brew-%EC%84%A4%EC%B9%98-%EB%B0%A9%EB%B2%95
겸사겸사 내 벨로그 한번 더 보게 하기~

1. postgresql 15 버전 설치

brew install postgresql@15
,,중략,,,
==> /opt/homebrew/Cellar/postgresql@15/15.2_3/bin/initdb --locale=C -E UTF-8 /opt/homebrew/var/postgresql@15
==> Caveats
This formula has created a default database cluster with:
  initdb --locale=C -E UTF-8 /opt/homebrew/var/postgresql@15
For more details, read:
  https://www.postgresql.org/docs/15/app-initdb.html

postgresql@15 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.

If you need to have postgresql@15 first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/postgresql@15/bin:$PATH"' >> ~/.zshrc

For compilers to find postgresql@15 you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/postgresql@15/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/postgresql@15/include"

To restart postgresql@15 after an upgrade:
  brew services restart postgresql@15
Or, if you don't want/need a background service you can just run:
  LC_ALL="C" /opt/homebrew/opt/postgresql@15/bin/postgres -D /opt/homebrew/var/postgresql@15
==> Summary
🍺  /opt/homebrew/Cellar/postgresql@15/15.2_3: 3,684 files, 61.0MB
==> Running `brew cleanup postgresql@15`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Caveats
==> postgresql@15
This formula has created a default database cluster with:
  initdb --locale=C -E UTF-8 /opt/homebrew/var/postgresql@15
For more details, read:
  https://www.postgresql.org/docs/15/app-initdb.html

postgresql@15 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.

If you need to have postgresql@15 first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/postgresql@15/bin:$PATH"' >> ~/.zshrc

For compilers to find postgresql@15 you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/postgresql@15/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/postgresql@15/include"

To restart postgresql@15 after an upgrade:
  brew services restart postgresql@15
Or, if you don't want/need a background service you can just run:
  LC_ALL="C" /opt/homebrew/opt/postgresql@15/bin/postgres -D /opt/homebrew/var/postgresql@15
jeongbyeong-ung@jeongbyeong-ung-ui-MacBookAir ~ % postgres --version

2. 환경 변수 설정하기

jeongbyeong-ung@jeongbyeong-ung-ui-MacBookAir ~ % echo 'export PATH="/opt/homebrew/opt/postgresql@15/bin:$PATH"' >> ~/.zshrc
jeongbyeong-ung@jeongbyeong-ung-ui-MacBookAir ~ % source ~/.zshrc
jeongbyeong-ung@jeongbyeong-ung-ui-MacBookAir ~ % export LDFLAGS="-L/opt/homebrew/opt/postgresql@15/lib"
jeongbyeong-ung@jeongbyeong-ung-ui-MacBookAir ~ % export CPPFLAGS="-I/opt/homebrew/opt/postgresql@15/include"
jeongbyeong-ung@jeongbyeong-ung-ui-MacBookAir ~ % postgres --version                                                        
postgres (PostgreSQL) 15.2 (Homebrew)

설치하고 나면 중간에 자세히 설명서(?) 같이 나와있는 것이 있는데 그곳에 설치 한 후 환경변수 관련 명령어가 어떻게 입력하면 되는지 나와있는데 그냥 위에 내가 써놓은 것을 하나씩 차례로 입력해주면 된다.

그리고 postgres --version을 입력해서 해당 버전에 맞는 정보를 출력하면 완료다.

3. 기동 방법

jeongbyeong-ung@jeongbyeong-ung-ui-MacBookAir ~ % brew services start postgresql@15
==> Successfully started `postgresql@15` (label: homebrew.mxcl.postgresql@15)

brew services start postgresql@15를 입력하면 기동이 된다.

4. 중지 방법

jeongbyeong-ung@jeongbyeong-ung-ui-MacBookAir ~ % brew services stop postgresql@15
Stopping `postgresql@15`... (might take a while)
==> Successfully stopped `postgresql@15` (label: homebrew.mxcl.postgresql@15)

brew services stop postgresql@15 를 입력하면 기동 중지가 된다.

profile
인생은 IT 노가다

0개의 댓글