環境:centos7 + pg 14
1:在postgresql官網下載頁面,根據提示下載
https://www.postgresql.org/download/linux/redhat/

2 連接到centos7服務器進行安裝
# Install the repository RPM: sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm # Install PostgreSQL: sudo yum install -y postgresql14-server # Optionally initialize the database and enable automatic start: sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
#設置開機啟動 sudo systemctl enable postgresql-14
#啟動服務 sudo systemctl start postgresql-14
3:配置pg,讓所有計算機能訪問到該測試數據庫
cd /var/lib/pgsql/14/data/
1:vim postgresql.conf
修改:
listen_addresses = 'localhost' 修改為:
listen_addresses = '*'
2:
vim pg_hba.conf
127.0.0.1/32 修改為 0.0.0.0/0 
        
4:賬號密碼修改
安裝pg后,centos會默認會創建一個名為postgres的linux登錄用戶,這里進行密碼修改
(注意,這里修改的是linux登陸的賬號密碼,不是數據庫的)
passwd postgres

重新啟動pg服務器
systemctl restart postgresql-14 
        
5:修改pg數據庫密碼
使用postgres 賬號密碼登錄ssh。

#進入pg psql -U postgres #修改密碼 \password
 
6;鏈接一下

7:卸載
yum remove postgresql*
參考文檔:
https://www.postgresql.org/download/linux/redhat/
https://www.cnblogs.com/xikui/p/12036360.html
https://www.jianshu.com/p/3f8d77d258d8
