データベース(PostgreSQL 8.3)の構築
データベース PostgreSQL 8.3 Serverのインストール
ビルド&インストール
# cd /usr/ports/database/postgresql83-server
# make install
# make clean
PostgreSQLの設定
データベースの初期化
# mkdir /usr/local/pgsql
# su -l pgsql -c 'initdb -D /usr/local/pgsql'
設定ファイルの編集
-
すべてのネットワークインターフェースからアクセスを受け付ける
-
-
/usr/local/pgsql/postgresql.conf
#listen_addresses = ’localhost'
を
#listen_addresses = '*'
-
-
-
/etc/rc.conf
postgresql_enable=“YES”
# optional
postgresql_data="/usr/local/pgsql"
を追加する
-
データベースを起動する。
# /usr/local/etc/rc.d/postgresql start
-
ps axで起動を確認する。
8158 ?? Is 0:00.29 /usr/local/bin/postgres -D /usr/local/pgsql 8160 ?? Ss 0:00.01 postgres: writer process (postgres) 8161 ?? Ss 0:00.01 postgres: wal writer process (postgres) 8162 ?? Ss 0:00.00 postgres: autovacuum launcher process (postgres) 8163 ?? Ss 0:00.00 postgres: stats collector process (postgres)
ユーザーの追加
自分とapacheで使えるようにwwwを追加する
# su -l pgsql -c 'createuser user1'
Shall the new role be a superuser? (y/n) y
# su -l pgsql -c 'createuser www'
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) y
テスト
テスト用データベースを作成する
# su -l pgsql -c 'createdb testdb'
データベースをリストアする
- データベース一覧
‘‘Name’’ | ‘‘Owner’’ | ‘‘Encoding’’ |
---|---|---|
bookmarkx | pgsql | EUC_JP |
egroupware | pgsql | SQL_ASCII |
linktsu.com@mt | user1 | SQL_ASCII |
linktsu.com@mt@at | user1 | EUC_JP |
mt_db | pgsql | SQL_ASCII |
ream | pgsql | SQL_ASCII |
www.sa-ku.com@mt | user1 | SQL_ASCII |
-
データベースを作成して、バックアップしておいたデータをリストアする
# su pgsql -c 'createdb -E EUC-JP bookmarkx' # su pgsql -c 'psql -e bookmarkx < dbbackup-bookmarkx' # su pgsql -c 'createdb mt_db' # su pgsql -c 'psql -e mt_db < dbbackup-mt_db' : :