1、準備工做:
1.postgresql官網:https://www.postgresql.org
2.下載頁面:https://www.postgresql.org/download/
3.Red Hat家族Linux(包括CentOS/Fedora/Scientific/Oracle)下載頁面:https://www.postgresql.org/download/linux/redhat/
4.本文使用系統爲:centos 7.5 1804
5.能夠使用一下網址找到對應的postgresql yum安裝版本 頁面:
https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
2、系統執行命令:
1.yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpmlinux
postgres=# ALTER USER postgres with encrypted password 'welcome1';
ALTER ROLE
postgres=# \q
-bash-4.2$ exit
logout
5、設置遠程訪問
命令:
vim /var/lib/pgsql/11/data/postgresql.conf
打開後找到:listen_addresses修改成:
listen_addresses = ''
要監聽的IP地址;以逗號分隔的地址列表;默認爲'localhost';對全部人使用''。修改完畢後保存關閉。sql
命令:
vim /var/lib/pgsql/11/data/pg_hba.conf
打開後文本新增內容以下:
host all all 0.0.0.0/0 md5
修改完成後保存關閉編輯。數據庫
六。重啓postgres 數據庫
systemctl restart postgresql-11vim