在CentOS7上安裝 postgreSQL11(在線安裝和離線安裝)


官方網站

官方網站下載: https://www.postgresql.org/download/linux/redhat/

 

1 在線安裝 postgresql11-server

# yum install
https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-
x86_64/pgdg-redhat-repo-latest.noarch.rpm
# yum install postgresql11-server

2 使用 yumdownloader 下載離線安裝包

1 安裝 yumdownloader

只想通過 yum 下載軟件的安裝包,但是不需要進行安裝的話,可以使用
yumdownloader 命令。
yumdownloader 命令在軟件包 yum-utils 里面。先安裝 yum-utils

yum install yum-utils -y

  

 

 

 

 

 

 

 2.安裝 rpm 資源庫

# yum install
https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-
x86_64/pgdg-redhat-repo-latest.noarch.rpm

  

 

 

 

 

 

 

3. 下載 postgresql11-server,不安裝

yumdownloader postgresql11-server

  

 

 

 

 

 

 

4. 安裝 postgresql11-server

# yum -y install *.rpm

 

 

 

5.初始化數據庫並設置自啟動


如果沒有設置環境變量 PGDATA,那么數據文件將安裝到
/var/lib/pgsql/11/data 目錄。

提示 :
也可以在初始化使用 -D 選項指定 例如 : $ initdb -D /data
需要首先創建一個 postgres 用戶,切換到該用戶下執行。
# /usr/pgsql-11/bin/postgresql-11-setup initdb
# systemctl enable postgresql-11
# systemctl start postgresql-11

  

6.登錄 pgSQL


在安裝完成以后如果,默認會在當前操作系統上創建一個 postgres 的用戶,密
碼隨機。

#使用管理員修改密碼
passwd postgres
#切換到 postgres
su postgres
#登錄 pgSQL
psql

  


7 修改 postgres 的密碼

# 修改 postgres 的密碼
postgres=# alter user postgres with password '自己的 password';
# 或者
postgres=# \password postgres

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM