普段MariaDB使ってる自分用の備忘録用なので、詳細な解説は省略しています。
環境はCentOS7.3 Postgresql9.2
インストール
yumからインストール
$ sudo yum install postgresql-server -y
db初期化
$ sudo postgresql-setup initdb
anyhost
$ sudo vi /var/lib/pgsql/data/postgresql.conf
デフォルトはlocalhost
listen_addresses = '*'
サーバー起動
$ sudo systemctl start postgresql
※これが出るときは初期化忘れてたりするかも。
Apr 5 14:17:03 localhost postgresql-check-db-dir: "/var/lib/pgsql/data" is missing or empty.
Apr 5 14:17:03 localhost postgresql-check-db-dir: Use "postgresql-setup initdb" to initialize the database cluster.
PSQL
postgresユーザー(初期ユーザー)パスワード設定
※本番環境では設定しないほうが良い?
基本OSユーザーなので、passwd
で変更。
$ sudo passwd postgres
postgresuserでpsqlコマンド実行
$ psql