(Postgresql) 설치하기

Database

설치 참고 링크

http://v_lovepooh_v.blog.me/20179692966 http://ngee.tistory.com/82

  1. postgreSQL 다운로드
$ wget http://ftp.postgresql.org/pub/source/v9.2.4/postgresql-9.2.4.tar.gz
  1. 설치
cd postgresql-<version>
./configure
make
make install

설치가 정상적으로 되었다면....아래의 경로에 폴더가 생성됨.

ls /usr/local/pgsql
  1. 유저 생성
$ useradd pgsql
$ passwd pgsql
  1. pgsql 디렉토리 권한 변경
$ chown -R pgsql:pgsql /usr/local/pgsql
  1. 환경변수 설정 .bash_profile 에 아래의 환경변수 추가 및 적용
export PG_HOME=/usr/local/pgsql
export PATH=$PG_HOME/bin:$PATH
export MANPATH=$PG_HOME/man
PGLIB=$PG_HOME/lib
PGDATA=$PG_HOME/data
  1. 초기데이타 생성
[pgsql@soul:/home/pgsql]$ initdb  -D pgdata
The files belonging to this database system will be owned by user "pgsql".
This user must also own the server process.

The database cluster will be initialized with locale "C".
The default database encoding has accordingly been set to "SQL_ASCII".
The default text search configuration will be set to "english".

creating directory pgdata ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
creating template1 database in pgdata/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
(...중략...)

Success. You can now start the database server using:

    postgres -D pgdata
or
    pg_ctl -D pgdata -l logfile start
  1. 데이타베이스 서버 실행
[pgsql@soul:/home/pgsql]$ postgres -D pgdata
LOG:  database system was shut down at 2013-08-22 17:22:37 KST
LOG:  autovacuum launcher started
LOG:  database system is ready to accept connections

또는

[pgsql@soul:/home/pgsql]$ pg_ctl -D pgdata -l logfile start
server starting
  1. 데이타베이스 생성
[pgsql@soul:/home/pgsql]$ createdb soul

생성한 데이타베이스에 접속

[pgsql@soul:/home/pgsql]$ psql -d soul
psql (9.2.4)
Type "help" for help.

soul=#
접속 방법
postgres@ubuntu:~$ psql souldb -U soul -W -h localhost
Password for user soul: tibero
psql (9.1.9)
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
Type "help" for help.

souldb=>