安裝:php
yum install postgresql-server service postgresql initdb chkconfig postgresql on
postgresql默認狀況下,遠程訪問不能成功,若是須要容許遠程訪問,須要修改兩個配置文件,說明以下:sql
# 以postgres用戶登陸數據庫,修改postgres用戶的數據庫密碼數據庫
psql -U postgres
postgres=# ALTER USER postgres PASSWORD '123456';
postgres=# \qvim
# 編輯配置文件,配置可訪問數據庫的網絡地址網絡
(注意別忘了去掉#listen_addresses=前面的#)dom
vim /var/lib/pgsql/data/postgresql.conf listen_addresses = '*'
# 編輯配置文件,設置密碼md5驗證socket
vim /var/lib/pgsql/data/pg_hba.conf # "local" is for Unix domain socket connections only local all all md5 # IPv4 local connections: #host all all 127.0.0.1/32 trust host all all 0.0.0.0/0 md5