카테고리 없음

MAC - Postgresql 설치

MuGrammer 2023. 9. 25. 12:42

공식 사이트 

https://www.postgresql.org/download/macosx/

 

PostgreSQL: macOS packages

macOS packages You can get macOS PostgreSQL packages from several different sources. Interactive installer by EDB Download the installer certified by EDB for all supported PostgreSQL versions. Note! This installer is hosted by EDB and not on the PostgreSQL

www.postgresql.org

 

Postgres.app
Postgres.app is a simple, native macOS app that runs in the menubar without the need of an installer. Open the app, and you have a PostgreSQL server ready and awaiting new connections. Close the app, and the server shuts down.

Homebrew
PostgreSQL can also be installed on macOS using Homebrew. For example, to install PostgreSQL 15, you can use the following command:

brew install postgresql@15

You can use Homebrew Formulae to search for PostgreSQL and other packages. To find a specific major version of PostgreSQL, search for postgresql@NN, where NN represents the major version. For example, postgresql@15.

 

Homebrew로 최신버전을 설치하도록 한다. 

 

brew install postgresql@15

 

 

 

설치가 끝나면 위와 같은 안내 문구가 출력된다. 

 

백그라운드 서비스 시작

brew services start postgresql@15
==> Successfully started `postgresql@15` (label: homebrew.mxcl.postgresql@15)

psql을 어느곳에서나 실행하려면 환경변수를 설정해줘야한다. 

echo 'export PATH="/opt/homebrew/opt/postgresql@15/bin:$PATH"' >> ~/.zshrc

쉘에 따라 변수를 설정하는 파일은 변경될 수 있을 것 같다. 

 

터미널 종료 후 재실행

 

psql -d postgres 를 실행하면 로컬 DB에 접속 할 수 있다. 

반응형