postgreSQL インストール

postgreSQLのinstallです。

インストール手順

#グループ作成
groupadd postgresql

#ディレクトリ作成
mkdir /usr/local/postgresql

#ユーザー作成
useradd -d /usr/local/postgresql -g postgresql postgresql

#解凍
tar xvzf postgresql-8.2.0.tar.gz

#突入
cd postgresql-8.2.0

#こんふぃぐ
./configure --prefix=/usr/local/postgresql/

#めいく
gmake

#ユーザー変更
su - postgresql

#ユーザーでテスト...All 103 tests passed.
gmake check

#rootに戻って
exit

#めいくいんすとーる
gmake install

#/usr/localで権限変えて
chown postgresql:postgresql -R postgresql/

                                                                                      • -

PostgreSQL installation complete.

                                                                                      • -

インストールはここまで
続いて、DB作成してログインします。

#DB作成場所設ける
mkdir /usr/local/postgresql/data
chown postgresql:postgresql -R /usr/local/postgresql/data

#作ってくれるスクリプト
su - postgresql
/usr/local/postgresql/bin/initdb -E EUC-JP -D /usr/local/postgresql/data --no-locale

#起動
/usr/local/postgresql/bin/pg_ctl -D /usr/local/postgresql/data -l logfile start

#データベース作成
./createdb test_db

#ログイン
./psql test_db

==============================================
test_db=# create table test_tbl(
test_db(# id int4,
test_db(# name varchar);
CREATE TABLE

test_db=# insert into test_tbl(id,name)values('1','postgresql');
INSERT 0 1

test_db=# select * from test_tbl;
id | name

                                • -

1 | postgresql
(1 row)

test_db-# \q
==============================================

こんな感じでうごいちょります。