linux安裝postgresql 12

1、 yum install -y https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-8.12-x86_64/pgdg-redhat-repo-latest.noarch.rpm

2、yum -y install postgresql12

3、yum -y install postgresql12-server

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

5、systemctl enable postgresql-12

6、systemctl start postgresql-12

7、su - postgres


#切換用戶后,提示符變更為“-bash-4.2$”;

#同時(shí)數(shù)據(jù)庫(kù)中也會(huì)生成一個(gè)名為”postgres”的數(shù)據(jù)庫(kù)用戶,且密碼已自動(dòng)生成;

#PostgreSQL在數(shù)據(jù)庫(kù)用戶同名的系統(tǒng)賬號(hào)下登錄免密;

psql -U postgres

#進(jìn)入數(shù)據(jù)庫(kù)后修改密碼;

postgres=# alter user postgres with password 'postgre';

\q 退出

exit 退出


這是外部是不能訪問的

8、找到pg_hba.conf? 一般在/var/lib/pgsql/12/data下


#在第82行之后,”IPv4 local connections”下新增允許的客戶端;

host all all 0.0.0.0/0 md5

9、?允許遠(yuǎn)程訪問

#默認(rèn)配置文件在/var/lib/pgsql/12/data/下postgresql.conf

#修改listen_addresses = 'localhost'為listen_addresses = '*',允許所有遠(yuǎn)程訪問;

10、設(shè)置環(huán)境變量

進(jìn)入配置文件 /etc/profile ,增加環(huán)境變量

export PATH=$PATH:/usr/pgsql-12/bin

11、重啟服務(wù)

systemctl restart postgresql-12

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

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