linux-centos7 離線rpm下載,通過yum安裝postgresql

1、下載需要安裝的對應(yīng)的postgresql 的 rpm包
https://yum.postgresql.org/rpmchart/

image.png

下載相同版本的rpm四個(gè)文件
image.png

2、通過xftp將文件上傳到對應(yīng)的服務(wù)器上
      sudo su - root 
     切換到root用戶
     通過命令進(jìn)入rpm包存放的路徑
       cd /home/centos/postgresql
     安裝postgresql所需要的依賴
       yum install gcc
       yum install gcc-c++
       yum install readline-devel
       yum install zlib-devel
     
     通過yum命令安裝rpm
       sudo yum install postgresql15-*
      
     安裝完成之后,需要初始化數(shù)據(jù)庫
       cd /usr/pgsql-15/bin/
        postgresql-15-setup initdb

    成功顯示:initializing database ... ok

    設(shè)置開機(jī)自啟
       sudo systemctl enable postgresql-15
    啟動(dòng)數(shù)據(jù)庫服務(wù)
       sudo systemctl start postgresql-15  
    
切換到postgres用戶
sudo su - postgres

使用psql連接到安裝好的數(shù)據(jù)庫
輸入命令:psql
psql(15.4)
Type "help" for help

此時(shí),數(shù)據(jù)庫連接成功
修改密碼:
postgres# alter role postgres with password 'postgres';

alter role;此時(shí),postgres用戶的密碼已修改成功,‘ ’ 里面是你的密碼

postgres# exit;
-bash-4.2$ exit;
logout;

    現(xiàn)在數(shù)據(jù)庫服務(wù)就安裝啟動(dòng)成功了,但是現(xiàn)在并不能實(shí)現(xiàn)遠(yuǎn)程連接安裝好的數(shù)據(jù)庫,還需要我們?nèi)プ鲆恍┡渲眯薷? 
    cd /var/lib/pgsql/13/data

    vim pg_hba.conf
在文件最下面添加一行配置
    host  all  all  0.0.0.0/0  md5
保存退出
image.png

(若有侵權(quán),請聯(lián)系刪除)

vim postgresql.conf
放開listen_addresses='localhost',并將 localhost改為*
開放端口號(hào) port=5432
保存退出
image.png
重啟postgresql服務(wù)器
sudo systemctl restart postgresql-15

systemctl start postgresql-15    // 啟動(dòng)服務(wù)
systemctl stop postgresql-15       // 關(guān)閉服務(wù)
systemctl restart postgresql-15   // 重啟服務(wù)
systemctl status postgresql-15     // 查看狀態(tài)



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

相關(guān)閱讀更多精彩內(nèi)容

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