centos8 安裝postgresql數據庫


  1. 登錄 postgresql 官網頁面
    https://www.postgresql.org/


2.下載安裝包
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

3.禁用內置的PostgreSQL模塊(這個時間較長)
sudo dnf -qy module disable postgresql

4.安裝PostgreSQL:
sudo dnf install -y postgresql13-server

5.初始化postgresql數據庫
sudo dnf install -y postgresql13-server

6.設置開機自啟動
sudo systemctl enable postgresql-13

7.啟動postgresql數據庫
sudo systemctl start postgresql-13

8.查看postgresql進程
ps -ef|grep postgre

9.通過netstat命令或者lsof 監聽默認端口5432
lsof -i:5432
netstat -an | grep 5432

10.使用find命令查找了一下postgresql.conf的配置位置
find -name postgresql.conf

11.修改postgresql.conf
listen_adress = '*'

12.修改認證文件並重啟
vim /var/lib/pgsql/13/data/pg_hba.conf

全部修改成 0.0.0.0/0 trust

13.登錄數據庫並修改密碼
psql -h 192.168.110.133 -d postgres -U postgres -p 5432
alter user postgres with password 'postgres';

14.修改認證文件把認證文件修改的trust改回來並重啟

可以通過密碼登錄啦!用遠程測試工具測試,注意是否開放服務器安全組

15.啟動,關閉命令
systemctl start postgresql-13
systemctl stop postgresql-13


免責聲明!

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



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