| トップ | Solaris | FreeBSD | Gentoo | CentOS | Fedora | Windows | Tips | 自宅サーバの動作確認 | サイト内検索(Namazu) | サイト内検索(HE) |
Gentoo ~ # emerge postgresql |
「PostgreSQL」管理者の設定
「PostgreSQL」をインストールすると管理者ユーザの postgres が作成されるので、パスワードを設定する。
ただし、Gentooのパスワードファイルが書き換えられる為、「/etc/passwd」と「/etc/shadow」の
整合性が取れなくなり、エラーが発生する場合がある。
この場合、「pwconv」コマンドにより、整合性をとる。
Gentoo上のパスワードの設定 Gentoo ~ # passwd postgres <= パスワードの変更 passwd: Authentication token manipulation error <= エラーが発生 Gentoo ~ # pwconv <= ファイルの整合性をとる Gentoo ~ # passwd postgres <= パスワードの変更 New UNIX password: <= パスワード Retype new UNIX password: <= パスワード(確認) passwd: password updated successfully <= パスワードが変更された |
データベース格納領域の初期化
Gentoo ~ # emerge --config =postgresql-8.0.8 |
Gentoo ~ # /etc/init.d/postgresql start |
「PostgreSQL」の自動起動
Gentooを起動する際に自動的に「PostgreSQL」を起動するようにします。
Gentoo ~ # rc-update add postgresql default |
「PostgreSQL」上のパスワードの設定
postgres の「PostgreSQL」上のパスワードを設定します。
Gentoo ~ # su - postgres <= 「PostgreSQL」の管理者に変更
postgres@Gentoo ~ $ psql template1 <= 「PostgreSQL」に接続
Welcome to psql 8.0.8, 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 with password '設定するパスワード'; <= 「PostgreSQL」上のpostgresユーザのパスワードを設定
ALTER USER
template1=# \q <= 終了
|
一般ユーザの設定
Gentoo ~ # su - postgres <= 「PostgreSQL」の管理者に変更 postgres@Gentoo ~ $ createuser -dPE kaz <= kazを「PostgreSQL」に登録 Enter password for new user: <= パスワード Enter it again: <= パスワード(確認) Shall the new user be allowed to create more new users? (y/n) n CREATE USER |
「postgresql.conf」ファイルの設定
Gentoo ~ # su - postgres <= 「PostgreSQL」の管理者に変更 postgres@Gentoo ~ $ vi /var/lib/postgresql/data/postgresql.conf <= 設定ファイルの編集 #listen_addresses = 'localhost' # what IP interface(s) to listen on; ↓ listen_addresses = 'localhost,192.168.0.1' # what IP interface(s) to listen on; <= 外部からの接続を受け付ける listen_addresses = '*' # what IP interface(s) to listen on; <= すべての接続を受け付ける場合 |
「pg_hba.conf」ファイルの設定
Gentoo ~ # su - postgres <= 「PostgreSQL」の管理者に変更 postgres@Gentoo ~ $ vi /var/lib/postgresql/data/pg_hba.conf <= 設定ファイルの編集 最終行に追加 host all all 192.168.0.0/24 trust <= 内部からのアクセスは許可 host all all 0.0.0.0/0 md5 <= 上記以外のアクセスはパスワードにより許可 |
「PostgreSQL」を再起動し、設定を反映させます。
Gentoo ~ # /etc/init.d/postgresql restart |