CentOS 7.5 1804 yum 安裝 PostgreSQL-11

一、準備工作:
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
二、系統執行命令:
1.yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm

  1. yum -y install postgresql11
  2. yum -y install postgresql11-server
  3. /usr/pgsql-11/bin/postgresql-11-setup initdb
  4. systemctl enable postgresql-11
  5. systemctl start postgresql-11
    三、開通PostgreSQL端口(如果防火牆關閉可以忽略此步驟)
  6. firewall-cmd --zone=public --add-port=5432/tcp --permanent
  7. firewall-cmd --reload
  8. firewall-cmd --list-ports
    四、設置postgres的密碼
    Last login: Fri Jul 19 17:13:49 CST 2019 on pts/0
    -bash-4.2$ psql -U postgres
    psql (11.4)
    Type "help" for help.

postgres=# ALTER USER postgres with encrypted password 'welcome1';
ALTER ROLE
postgres=# \q
-bash-4.2$ exit
logout
五、設置遠程訪問
命令:
vim /var/lib/pgsql/11/data/postgresql.conf
打開後找到:listen_addresses修改爲:
listen_addresses = ''
要監聽的IP地址;以逗號分隔的地址列表;默認爲'localhost';對所有人使用'
'。修改完畢後保存關閉。

命令:
vim /var/lib/pgsql/11/data/pg_hba.conf
打開後文本新增內容如下:
host all all 0.0.0.0/0 md5
修改完成後保存關閉編輯。

六。重啓postgres 數據庫
systemctl restart postgresql-11

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章