溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

CentOS7安裝PostgreSQL12的方法

發(fā)布時間:2020-05-25 15:45:32 來源:億速云 閱讀:308 作者:鴿子 欄目:云計算

1、進入官網(wǎng)下載所需版本

https://www.postgresql.org/download/linux/redhat/

CentOS7安裝PostgreSQL12的方法2、開始安裝

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

CentOS7安裝PostgreSQL12的方法

yum install postgresql12 -y

yum install postgresql12-server -y

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

/usr/pgsql-12/bin/postgresql-12-setup initdb

systemctl enable postgresql-12

systemctl start postgresql-12

CentOS7安裝PostgreSQL12的方法

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

4、默認會創(chuàng)建一個名為postgres的linux登錄用戶,這里進行密碼修改

CentOS7安裝PostgreSQL12的方法

5、修改配置文件

CentOS7安裝PostgreSQL12的方法

5.1修改postgresql.conf
修改:#listen_addresses = 'localhost'為listen_addresses = '*'

CentOS7安裝PostgreSQL12的方法

5.2修改pg_hba.conf

修改前

CentOS7安裝PostgreSQL12的方法

修改后

CentOS7安裝PostgreSQL12的方法

并重新啟動

systemctl restart postgresql-12

6、設(shè)置登錄數(shù)據(jù)庫賬密

su postgres              #不能使用root用戶登錄,切換到普通用戶

psql -U postgres         

\password                #設(shè)置用戶密碼

select version();        #查看版本

CentOS7安裝PostgreSQL12的方法

7、登錄并測試數(shù)據(jù)庫連接

CentOS7安裝PostgreSQL12的方法

CentOS7安裝PostgreSQL12的方法

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI