PostgreSQL 9.4.11 をインストール

2017年4月5日(約7年前)の記事となっております。色々ご注意ください。

今回は、GitLab のデータベースをMySQL から PostgreSQL に変換するためにインストールします。

関連記事
GitLab 9.0.2 ソースインストール版からGitLab CE Omnibusに移行

環境

rpm -qa | grep centos-release
centos-release-6-8.el6.centos.12.3.x86_64

インストール

vi /etc/yum.repos.d/CentOS-Base.repo
[base]
exclude=postgresql*
[updates]
exclude=postgresql*
yum localinstall http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-3.noarch.rpm
yum list postgresql*
yum install postgresql94-server
psql -V
psql (PostgreSQL) 9.4.11

初期化

service postgresql-9.4 initdb
chkconfig postgresql-9.4 on
chkconfig --list postgresql-9.4

基本操作

手動起動

service postgresql-9.4 start

手動停止

service postgresql-9.4 stop

初期設定

posgresユーザーが作成されていることを確認

id postgres

PostgreSQLの操作は、 postgres ユーザーで行う。

su postgres

以降、postgresで実行

データベースの一覧

psql -l

パスワードを設定

psql -U postgres
ALTER USER postgres with encrypted password 'パスワード';
\q

ユーザーを作成

createuser shinohara

shinohara は任意で変更してください

n, y, y で返答

※ 同名のlinuxユーザーが無ければ、linuxユーザーを用意する必要あり

PostgreSQLに接続するときのパスワードは、Linuxパスワードになるので、パスワードを設定していないLinuxユーザーの場合は、パスワードの設定の必要あり。

vi /var/lib/pgsql/9.4/data/pg_hba.conf