阿里雲CentOS安裝PostgreSQL

在PostgreSQL官方文檔:https://www.postgresql.org/download/linux/redhat/ 有選項和說明

一、檢查有沒安裝:rpg -ga | grep postgresqllinux

二、下載 從上述網址獲得YUM地址,即在終端輸入:yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpmsql

      注意:整個YUM必須都是小寫的命令,Unix嚴格區分大小寫(經過阿里雲遠程終端複製粘貼的是大寫字母,不可用)數據庫

三、安裝,終端輸入:yum install postgresql11-server postgresql11-libsvim

四、初始化:/usr/pgsql-11/bin/postgresql-11-setup initdb (注意這裏必需要輸入完整路徑...)centos

五、配置服務安全

systemctl enable postgresql-11服務器

systemctl start postgresql-11post

 

六、配置遠程鏈接:阿里雲

vim /var/lib/pgsql/11/data/postgresql.conf  將listen_addresses 修改成 '*'加密

vim /var/lib/pgsql/11/data/pg_hba.conf  添加IP監聽(加入一行) host all all 0.0.0.0/0 md5

重啓服務:systemctl restart postgresql-11

七、修改數據庫密碼,以postgres爲例:

      經過命令切換用戶: su - postgres

      使用命令更改密碼(用MD5加密):alter role postgres with ENCRYPTED password '123456'

 

      能夠使用命令查看是否能登陸:psql -h 127.0.0.1 -U postgres -d 123456 -W

八、配置ECS服務器的《安全組》策略

 

九、最後查看ECS實例公網地址,在外網訪問

相關文章
相關標籤/搜索