1.下載安裝包
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
2.關(guān)閉內(nèi)置PostgreSQL模塊:
sudo dnf -qy module disable postgresql
3.安裝postgresql服務(wù):
sudo dnf install -y postgresql13-server
4.初始化postgresql數(shù)據(jù)庫:
sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
5.設(shè)置開機(jī)自啟動:
sudo systemctl enable postgresql-13
6.啟動postgresql數(shù)據(jù)庫
sudo systemctl start postgresql-13
7.查看postgresql進(jìn)程
ps -ef|grep postgre
8.通過netstat命令或者lsof 監(jiān)聽默認(rèn)端口5432
lsof -i:5432
netstat -an | grep 5432
9.使用find命令查找了一下postgresql.conf的配置位置
cd /
find -name postgresql.conf
vim /var/lib/pgsql/13/data/postgresql.conf
10.修改postgresql.conf
listen_adress = '*'
11.修改認(rèn)證文件并重啟
vim /var/lib/pgsql/13/data/pg_hba.conf
(1)"trust"和"password"為postgresql數(shù)據(jù)庫登陸驗(yàn)證的方式,"trust"表示信任,即不需要輸入密碼(即使有密碼),"password"表示需 要輸入密碼。
(2).host all all 127.0.0.1/31 trust表示本地連接數(shù)據(jù)庫不需要輸入密碼(即使有密碼,設(shè)為trust后就不需要密碼)
(3).host all all 0.0.0.0/0 所有主機(jī)連接數(shù)據(jù)庫需要輸入密碼(如果有密碼)
(4).當(dāng)然,這兩個(gè)綜合后表現(xiàn)的結(jié)果就是:對于本機(jī)鏈接表示信任(不需要輸入密碼),對于非本機(jī)鏈接需要輸入密
12. 登錄數(shù)據(jù)庫并修改密碼
su postgres
psql
ALTER USER postgres WITH PASSWORD '4ZwgL1dvvrnl2N';
\q
exit
文章來源:http://www.zghlxwxcb.cn/news/detail-620531.html
13.防火墻
查看已開啟列表
firewall-cmd --list-ports
開啟端口
firewall-cmd --zone=public --add-port=5432/tcp --permanent
重新加載
firewall-cmd --reload
再次查看
firewall-cmd --list-ports
文章來源地址http://www.zghlxwxcb.cn/news/detail-620531.html
到了這里,關(guān)于41. linux通過yum安裝postgresql的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!