티스토리 뷰

Database/POSTGRESQL

Mac PostgreSQL 설치

서보민 2018. 3. 12. 21:06

MacOS PostgreSQL 설치

설치환경

  • MacOS
  • homebrew버전 : homebrew 1.3.2
  • PostgreSQL Version : v9.6

목차

homebrew

homebrew?

  • 리눅스 터미널에서는 wget이나 yum으로 패키지 관리를 손쉽게 할 수 있지만 리눅스 계열인 mac os에서는 이러한 기능이 없다.

    그래서 나온게 HomeBrew이다.

설치법

  • 홈페이지에 접속 : [brew 홈페이지]

  • 가운데 부분에 위치한 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 이 부분을 복사해 터미널에 붙여 넣으면 된다. 

간단한 사용법

  • 패키지 검색

    ~$ brew search [패키지명];
  • 패키지 설치

    ~$ brew install [패키지명];
  • 패키지 삭제

    ~$ brew uninstall [패키지명];
  • homebrew 업데이트, 패키지 업그레이드, 과거 버전 제거

    ~$ brew update; brew upgrade; brew cleanup

Postgresql 설치

앞서 설치한 homebrew를 이용해 Postgresql을 설치한다. 명령어는 간단하다.

설치

 ~$ brew search postgresql      //postgres를 찾는다.
 
 ~$ brew install postgresql //postgres를 설치한다.

설치 확인

postgresql설치경로/bin/postgres --version 

예)
~$ /usr/local/opt/postgresql/bin/postgres --version

설치가 정상적이라면 postgres (PostgreSQL) 9.6.5라는 문구가 나오게 된다. 

postgres (PostgreSQL) 9.6.5문구를 확인했다면 이제 postgresql 서비스를 시작한다. 

Postgresql 서비스 시작

~$ postgres -D /usr/local/var/postgres

접속 테스트

~$ psql –U postgres –d postgres

 -U : 사용자ID
 -d : 데이터베이스명

database 생성

postgres$ CREATE DATABASE database_name ENCODING 'encoding_type';

예)
postgres$ CREATE DATABASE homepage ENCODING 'utf-8';

user 생성

 postgres$ create user user_name password 'passwd';
 
 예)
 postgres$ create user scott password 'tiger';

database 소유권 user에게 주기

 postgres$ alter database database_name owner to user_name;
 
 예)
  postgres$ alter database testdb owner to scott;

user 권한 주기

 postgres$ grant all on database database_name to user_name with grant option;
 
 예)
  postgres$ grant all on database testdb to scott with grant option;

(scott) 유저 접속 테스트

 ~$ psql –U postgres –d postgres

 예)
  ~$ psql -U scott -d testdb


'Database > POSTGRESQL' 카테고리의 다른 글

우분투 PostgreSQL 설치  (2) 2018.03.12
postgresql upgrade  (0) 2018.03.12
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
TAG
more
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함