■初期設定
まずは自動起動をonにします。
# /sbin/chkconfig postgresql on
次にとりあえずサーバを起動します。
# /etc/init.d/postgresql start
初期化が終了しサーバが起動します。
そしたら、次はUNIXのpostgresユーザのパスワードを設定します。
# passwd postgres Changing password for user postgres. New UNIX password: Retype new UNIX password: passwd: all authentication tokens updated successfully.
続いてPostgreSQL 内で管理するスーパーユーザー postgres にパスワードを設定します。
こちらは先ほどの Unix アカウントとは異なります。
インストール時に事前に用意されているデータベース template1 にpsql コマンドで接続します。
(psql の実行は必ずデータベースに接続する必要がある) また、# はスーパーユーザー権限でデータベースに接続していることを示します。
# su - postgres
-bash-3.00$ psql template1
Welcome to psql 8.1.11, the PostgreSQL interactive terminal.
Type: copyright for distribution terms
h for help with SQL commands
? for help with psql commands
g or terminate with semicolon to execute query
q to quit
template1=# alter user postgres password 'パスワード';
ALTER ROLE
template1=# q
-bash-3.00$ logout
次に、いつも使うユーザを追加します。
# su - postgres -bash-3.00$ createuser -P Enter name of role to add: webmaster Enter password for new role: パスワードを入力 Enter it again: 入力したパスワードの確認 Shall the new role be a superuser? (y/n) y #スーパーユーザー特権を許可するかどうかです。 CREATE ROLE
webmasterの部分はお好きなユーザ名に変更して下さい。
次に、PostgreSQL認証設定ファイルを編集
-bash-3.00$ vi /var/lib/pgsql/data/pg_hba.conf 以下の部分を変更 local all all md5 host all all 127.0.0.1/32 md5 (アクセスはユーザ認証) 保存する -bash-3.00$ logout # /etc/init.d/postgresql restart (再起動) postgresql サービスを停止中: [ OK ] postgresql サービスを開始中: [ OK ] # psql -U webmaster template1
として、ログインできればOKです。