PostgreSQL
| インストール Japan PostgreSQL User Group | |
| 1 |
useradd postgres mkdir /usr/local/src/postgresql-7.2.3 chown postgres:postgres /usr/local/src/postgresql-7.2.3 mkdir /usr/local/pgsql chown postgres:postgres /usr/local/pgsql |
| 2 | postgresになった後以下を実行します。
su - postgres |
| 3 | パスの設定と環境変数の設定 $ vi ~/.bash_profile .bash_profile の内容の最後に以下を追加: -------------------------------------------------------------------- export PATH="$PATH":/usr/local/pgsql/bin export POSTGRES_HOME=/usr/local/pgsql export PGLIB=$POSTGRES_HOME/lib export PGDATA=$POSTGRES_HOME/data export MANPATH="$MANPATH":$POSTGRES_HOME/man export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"$PGLIB" -------------------------------------------------------------------- |
| 4 | 設定の反映
$ source ~/.bash_profile |
| 以上でインストール完了! | |
| DBの初期化 $ /usr/local/pgsql/bin/initdb -E EUC_JP -D /usr/local/pgsql/data |
|
| DBスタート $ /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -o "-S -i" start |
|
| 自動起動の設定 > vi /etc/rc.d/rc.local |
|
| テーブル毎バックアップ > su - postgres $ pg_dump -Fc -b データベース名 > db_archive.dump (バイナリを圧縮) リストア > su - postgres $ createdb -T template0 データベース名 $ pg_restore -d データベース名 db_archive.dump |
| フルバックアップ $ pg_dumpall -o | gzip > ファイル名.gz 解凍・リストア $ gunzip -c ファイル名.gz $ psql -e template1 < 解凍されたファイル |
| phpPgAdminのインストール phpPgAdmin | |
| 1 |
展開 # tar zxvf phpPgAdmin-3.5.3.tar.gz |
| 2 |
configのコピー&修正 # cp phpPgAdmin/conf/config.inc.php-dist conf/config.inc.php # vi phpPgAdmin/conf/config.inc.php ----------------------------------------- $conf['servers'][0]['host'] = 'localhost'; $conf['default_lang'] = 'japanese'; ----------------------------------------- # vi phpPgAdmin/classes/database/Postgres.php ----------------------------------------- 'SQL_ASCII' => 'EUC-JP', ----------------------------------------- |
| 3 |
セキュリティー上htdocsと同一階層へ移動 # mv phpPgAdmin /data |
| 4 |
httpd.confの設定 # vi /usr/local/apache/conf/httpd.conf 以下を追記 ----------------------------------------- Alias /pgadmin /data/phpPgAdmin ----------------------------------------- |
| 5 |
apacheの再起動 # /usr/local/apache/bin/apachectl configtest # /usr/local/apache/bin/apachectl restart |
| 6 | (必要があればpostgresユーザーを新規作成) |