CentOS 7.5 1804 yum 安裝 PostgreSQL-11

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

  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
    3、開通PostgreSQL端口(若是防火牆關閉能夠忽略此步驟)
  6. firewall-cmd --zone=public --add-port=5432/tcp --permanent
  7. firewall-cmd --reload
  8. firewall-cmd --list-ports
    4、設置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
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

相關文章
相關標籤/搜索