PostgreSQL8.3をCentOS5.3にインストール
まずインストール済みのPostgreSQLがあればアンインストールします。
インストール済みのPostgreSQLのパッケージを検索します。
yum list installed | grep postgresql
以下のような結果が返ってきたらインストールされています。
postgresql-libs.i386 8.1.11-1.el5_1.1 base
アンインストールするには
yum remove postgresql-libs
以上でアンインストールは完了です。
次に必要なバージョンのRPMを取得します。
8.3をインストールするためにここからRPMを取得します。
RPMのダウンロードが完了したら展開します。
wget http://yum.pgsqlrpms.org/reporpms/8.3/pgdg-centos-8.3-6.noarch.rpm rpm -ivh pgdg-centos-8.3-6.noarch.rpm
正常に完了すると /etc/yum.repos.d/pgdg-83-centos.repo が追加されます。
/etc/yum.repos.d/CentOS-Base.repo の[base]、[updates]の最後にそれぞれ exclude=postgres* を追加します。
[base] name=CentOS-$releaserver - Base ・ ・ exclude=postgres* [updates] name=CentOS-$releaserver - Updates ・ ・ exclude=postgres* [addons] ・ ・
ここまで終わったらyumでさっき追加したリポジトリを使用してインストールします。
yum install postgresql yum install postgresql-server yum install postgresql-contrib yum install postgresql-devel
インストールが完了したらデータベースを初期化します。
service postgresql initdb または initdb --encoding=UTF8 --no-locale
/var/lib/pgsql/pgstartup.log を確認してエラーが発生していないことを確認します。
起動
/etc/rc.d/init.d/postgresql start または service postgresql start
postgresユーザのパスワードを設定します。(CentOSのパスワード)
passwd postgres New UNIX password: Retype New UNIX password:
postgresユーザのPostgreSQLでのパスワードを設定します。
su - postgres psql -Upostgres postgres ALTER USER postgres WITH PASSWORD 'postgres'; \q exit
このあとは通常のユーザ(rootやその他のユーザ)でpsqlコマンドを使用してPostgreSQLを利用できます。
ALTER USERで設定したパスワードを使用します。
psql -Upostgres postgres Password for user postgres: postgres
/var/lib/pgsql/data/pg_hba.confの設定を変更します。
# "local" is for UNIX domain socket connections only #local all all ident sameuser local all all md5 # IPv4 local connections #local all all 127.0.0.0/32 ident sameuser local all all 127.0.0.0/32 md5 # IPv6 local connections #local all all ::1/128 ident sameuser local all all ::1/128 md5
再起動します。
service postgresql restart