CentOS7 PostgreSQL

postgreSQLのインストについてブログに何も残していなかったので・・・

# yum -y install postgresql-server
完了しました!
# postgresql-setup initdb
Initializing database ... OK

この時点で、postgreSQLは、/var/lib/pgsql/にインストされる。

# cd /var/lib/pgsql/data
# cp postgresql.conf postgresql.conf.org
# echo "listen_addresses = '*'" >> /var/lib/pgsql/data/postgresql.conf
# cp pg_hba.conf pg_hba.conf.org
# echo "# PostgreSQL Client Authentication Configuration File" > ./pg_hba.conf
# echo "# ===================================================" >> ./pg_hba.conf
# echo "local all all trust" >> ./pg_hba.conf
# echo "host all all 127.0.0.1/32 trust" >> ./pg_hba.conf
# echo "host all all ::1/128 trust" >> ./pg_hba.conf
# echo "host all all 192.168.***.0/24 md5" >> ./pg_hba.conf
# systemctl start postgresql
# systemctl enable postgresql
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql.service to /usr/lib/systemd/system/postgresql.service.

最後の192.168.***.0/24でLANから繋げる様にする。***部分は、LAN環境によって違うだろう。#ip  aで確認。

# psql -U postgres
 \password
新しいパスワード: *******
もう一度入力してください:*******

でパスワードを設定する。もっともpg_hba.confでtrust設定したIPアドレスならパスワードは何でもいい。
phpPgAdminのインストール

# yum -y install phpPgAdmin
・・・
Require local
を
Require  all granted
に変える
・・・
$conf['servers'][0]['host'] = '';
を
$conf['servers'][0]['host'] = '127.0.0.1';
・・・
他にも繋ぐなら
$conf['servers'][1]['host'] = '192.168.***.***';
の要領で配列を増やす。
※その分画面にサーバーの接続先が増えるが、配列の他の要素も[0]の分だけ追加しなければいけない。
・・・
information_schemaなどを表示する場合は
$conf['show_system'] = true;
※いっぱいゾロゾロと出てくるので普通はfalseでいいだろう。
#systemctl restart httpd

で再設定させて、ブラウザからhttp://192.168.***.***/phpPgAdmin/で開き、postgresでログインする。
あ、WindosなどからPgAdminなどで繋ぐには仮想マシンならホストからもポート5432を解放しないといけないだろう。

# firewall-cmd --add-port=5432/tcp --zone=public --permanent



コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA