PostgreSQL 10 を CentOS 7 に yum インストールする

PostgreSQL公式リポジトリを追加します。

# yum -y localinstall https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm


パッケージを確認します。

# yum info postgresql10-server


PostgreSQL 10 が PostgreSQLリポジトリで提供されていることを確認できたので、インストールします。

# yum -y install postgresql10-server


インストールされた PostgreSQL のバージョンを確認します。

# /usr/pgsql-10/bin/postgres --version


インストールが完了したら、データベースを初期化します。

# /usr/pgsql-10/bin/postgresql-10-setup initdb


PostgreSQLをサービス化します。

# systemctl enable postgresql-10


PostgreSQLを起動します。

# systemctl start postgresql-10


PostgresSQLをインストールすると、pstgresユーザーが作成されます。
postgresユーザーのパスワードは設定されていません。
パスワードを設定します。

# su - postgres
$ psql
postgres=# ALTER ROLE postgres PASSWORD 'xxxxxxxxxx';
postgres=#  \q