教你如何在Centos8-stream安裝PostgreSQL13
一、安裝postgresql13-server
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm yum install -y postgresql13-server
二、初始化PostgreSQL
先創(chuàng)建postgresql儲存目錄
mkdir /home/pgsql-13 chmod 777 /home/pgsql-13 #授予權限,否則后續(xù)初始化是會報錯
切換postgres用戶正式初始化
su postgres /usr/pgsql-13/bin/initdb -D /home/pgsql-13/data

三、啟動postgresql數(shù)據(jù)庫
cd /home/pgsql-13 /usr/pgsql-13/bin/pg_ctl -D /home/pgsql-13/data -l logfile start
這里注意繼續(xù)使用postgres用戶操作,否則會報錯

四、修改配置文件和創(chuàng)建數(shù)據(jù)庫密碼和數(shù)據(jù)庫
vi /home/pgsql-13/data/postgresql.conf listen_addresses = ‘localhost' #開放本地登錄 port = 5432 #開放登錄端口 psql ALTER USER postgres WITH PASSWORD '(123456)'; #將123456替換成自己設定的數(shù)據(jù)庫密碼 CREATE DATABASE mytest; #創(chuàng)建數(shù)據(jù)庫 \q #退出操作
結果如下圖:

五、添加遠程訪問權限:
vi /home/pgsql-13/data/pg_hba.conf host all all 0.0.0.0/0 md5 #結尾處添加

六、配置開機啟動數(shù)據(jù)庫腳本
mkdir /home/pgsql-13/bin vi /home/pgsql-13/bin/startup.sh
輸入一下內(nèi)容:
#! /bin/bash su postgres<<! cd /home/pgsql-13 /usr/pgsql-13/bin/pg_ctl -D /home/pgsql-13/data -l logfile start exit $? !
添加腳本路徑
chmod -R 755 startup.sh vi /etc/rc.local /home/pgsql-13/bin/startup.sh #在文件內(nèi)容最后一行添加
七、數(shù)據(jù)庫定時備份腳本
mkdir -p /home/pgsql-13/backdata chmod 777 /home/pgsql-13/backdata mkdir -p /home/pgsql-13/backdata/bin vi /home/pgsql-13/backdata/bin/backup.sh
輸入如下內(nèi)容:
#! /bin/bash t=KaTeX parse error: Expected group after '_' at position 112: …ip > backupfile_?t.sql.gz find /home/pgsql-13/backdata -mtime 7 -type f|xargs rm -f exit $? !
配置定時任務:
12 2 * * * /home/pgsql-13/backdata/bin/backup.sh
參考網(wǎng)站:https://www.postgresql.org/download/linux/redhat/
PostgreSQL 13.1 手冊 http://postgres.cn/docs/13/index.html
到此這篇關于Centos8-stream安裝PostgreSQL13的文章就介紹到這了,更多相關Centos8安裝PostgreSQL13內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
關于PostgreSql數(shù)據(jù)庫與mysql數(shù)據(jù)庫的不同點以及注意事項
PostgreSQL和MySQL是兩種流行的關系型數(shù)據(jù)庫管理系統(tǒng)(RDBMS),它們都可以用來存儲和管理數(shù)據(jù),但是它們在某些方面有所不同,下面這篇文章主要給大家介紹了關于PostgreSql數(shù)據(jù)庫與mysql數(shù)據(jù)庫的不同點以及注意事項的相關資料,需要的朋友可以參考下2023-05-05
postgresql 實現(xiàn)字符串分割字段轉列表查詢
這篇文章主要介紹了postgresql 實現(xiàn)字符串分割字段轉列表查詢,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-02-02
在windows下手動初始化PostgreSQL數(shù)據(jù)庫教程
在windows下手動初始化PG,是一件比較麻煩的事,下面我具體寫一下過程,大家做一下參考。2014-09-09
postgresql 中的幾個 timeout參數(shù) 用法說明
這篇文章主要介紹了postgresql中的幾個timeout參數(shù)用法說明,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-01-01
Postgresql數(shù)據(jù)庫SQL字段拼接方法
Postgresql里面內(nèi)置了很多的實用函數(shù),下面這篇文章主要給大家介紹了關于Postgresql數(shù)據(jù)庫SQL字段拼接方法的相關資料,文中通過代碼介紹的非常詳細,需要的朋友可以參考下2023-11-11
使用python-slim鏡像遇到無法使用PostgreSQL的問題及解決方法
這篇文章主要介紹了使用python-slim鏡像遇到無法使用PostgreSQL的問題及解決方法,本文給大家介紹的非常詳細,感興趣的朋友跟隨小編一起看看吧2024-08-08
使用PostGIS完成兩點間的河流軌跡及流經(jīng)長度的計算(推薦)
這篇文章主要介紹了使用PostGIS完成兩點間的河流軌跡及流經(jīng)長度的計算,使用POSTGIS及其擴展pgrouting計算給定兩點間的河流流經(jīng)區(qū)域和河流長度,需要的朋友可以參考下2022-01-01

