1.포스트그레스 설치

sudo apt-get install postgresql


2.비밀번호변경

#접속

#postgre는 기본 root계정

sudo -u postgres psql


#비밀번호 변경

#아래의 프롬프트에서

postgres=#


ALTER USER postgres with encrypted password 'password';


#종료

\q


3.로컬접속 허용

#루트권한으로 변경해야한다.

변경 파일 : postgresql.conf

루트 : /etc/postgresql/9.3/main/

변경 : sudo gedit /etc/postgresql/9.3/main/


#주석제거

#listen_addresses = 'localhost'

-> listen_addresses = 'localhost'



4.접속시 비밀번호 입력 변경

#루트권한으로 변경해야한다.

변경 파일 : pg_hba.conf

루트 : /etc/postgresql/9.3/main/

변경 : sudo gedit /etc/postgresql/9.3/main/pg_hba.conf


# Database administrative login by Unix domain socket
local   all             postgres                               peer


-> local   all             postgres                                md5


# md5로 권한을 바꾸어 항상 비밀번호를 넣어서 실행시키도록 변경하자.



5.원격접속 허용

변경 파일 : postgresql.conf

listen_addresses = '*'


변경 파일 : pg_hba.conf


# IPv4 local connections:
host    all             all             127.0.0.1/32            md5

-> host    all             all             0.0.0.0/0           trust




5.적용

#재시작

sudo /etc/init.d/postgresql restart

혹은

sudo service postgresql restart



6.pgAdmin 설치

sudo apt-get install pgadmin3


#GUI툴로 사용하기 용이하다.



6.데이터베이스 만들기

sudo -u postgres createdb db-name


참조

http://wonzopein.com/45

Posted by bbd531
,