centos7 安裝postgresql11

1 進(jìn)入postresql官網(wǎng)下載頁面,提示了centos相關(guān)下載安裝等信息。
https://www.postgresql.org/download/linux/redhat/

image.png

2 連接到centos7服務(wù)器


image.png

3 根據(jù)官網(wǎng)提示在命令行中下載安裝

yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
image.png
yum install postgresql11
yum install postgresql11-server

附帶安裝

yum install postgresql11-libs
yum install postgresql11-contrib 
yum install postgresql11-devel

4 數(shù)據(jù)庫初始化與設(shè)置自啟動

/usr/pgsql-11/bin/postgresql-11-setup initdb
systemctl enable postgresql-11
systemctl start postgresql-11
image.png

這一步初始化數(shù)據(jù)庫命令會在 /var/lib/pgsql 目錄下創(chuàng)建名稱為11文件夾,11為數(shù)據(jù)庫版本,如果安裝的是其他版本,對應(yīng)的是其版本號(9.4、9.5);這里如果已經(jīng)有對應(yīng)版本的文件夾了,初始化這一步會報(bào)錯,需要你自行去刪除對應(yīng)的文件夾,再去初始化。

5 默認(rèn)會創(chuàng)建一個名為postgres的linux登錄用戶,這里進(jìn)行密碼修改
(注意,這里修改的是linux登陸的賬號密碼,不是數(shù)據(jù)庫的)

passwd postgres
image.png

6 編輯一些遠(yuǎn)程連接信息,讓所有計(jì)算機(jī)能訪問到該測試數(shù)據(jù)庫
6.1 對postgresql.conf文件進(jìn)行編輯

cd var/lib/pgsql/11/data
vim postgresql.conf

修改前:


image.png

輸入a進(jìn)入插入編輯模式,對該文件進(jìn)行編輯;
去掉#,修改localhost為*

修改后如下,按下esc退出插入編輯模式,并輸入:wq保存退出


image.png

6.2同樣目錄下,對pg_hba.conf文件進(jìn)行編輯

vim pg_hba.conf

修改前:


image.png

輸入a進(jìn)入插入編輯模式,對該文件進(jìn)行編輯

修改后如下,按下esc退出插入編輯模式,并輸入:wq保存退出


image.png

7 重新啟動服務(wù)

systemctl restart postgresql-11

8 用postgres賬號登錄centos服務(wù)器,并修改數(shù)據(jù)庫用戶密碼(或者直接 su postgres 切換過去)

ssh postgres@ip -p 端口
psql -U postgres
 \password
image.png

查看版本


image.png

9 在數(shù)據(jù)庫客戶端測試登錄


image.png

10 備用卸載

yum remove postgresql*
image.png

前人經(jīng)驗(yàn)參考
http://www.itdecent.cn/p/3f8d77d258d8
http://www.itdecent.cn/p/639ebb43bfb4
https://www.cnblogs.com/freeweb/p/8006639.html
http://www.postgresonline.com/article_pfriendly/362.html
https://www.cnblogs.com/yanmiao/p/3262306.html


參考
PostgreSQL 11 有哪些引人矚目的新特性

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容