技術関連の覚書

案件でやったり自宅で試したことの覚書

PostgreSQL

インストール

yum -y install postgresql postgresql-server

postgresql-setup initdb

/var/lib/pgsql/data/postgresql.confの編集

#listen_addresses = 'localhost'         # what IP address(es) to listen         on; <=ローカルホストのみ、コメントアウト
listen_addresses = '*'          # what IP address(es) to listen on; <= コメントアウトを外して、全ホストからのアクセスを許可
[root@zeke ~]# systemctl start postgresql
[root@zeke ~]# systemctl enable postgresql
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql.service to /usr/lib/systemd/system/postgresql.service.

[root@zeke ~]# firewall-cmd --add-service=postgresql --permanent
success
[root@zeke ~]# firewall-cmd --reload
success

[root@zeke ~]# firewall-cmd --add-service=postgresql --permanent
success
[root@zeke ~]# firewall-cmd --reload
success

初期設定

デフォルトユーザ(postgres)のパスワード変更

[root@zeke ~]# su - postgres
-bash-4.2$ psql -c "alter user postgres with password 'password'" 
ALTER ROLE

ユーザとDBの作成

-bash-4.2$ createuser user
-bash-4.2$ createdb dbname -O user