Linux安裝Postgresql

一 、yum安裝

二、離線安裝

1 安裝包和依賴(lài)下載

wget http://mirror.centos.org/centos/7/os/x86_64/Packages/libicu-50.2-4.el7_7.x86_64.rpm
wget https://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/postgresql96-9.6.20-1PGDG.rhel7.x86_64.rpm
wget https://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/postgresql96-libs-9.6.20-1PGDG.rhel7.x86_64.rpm
wget https://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/postgresql96-server-9.6.20-1PGDG.rhel7.x86_64.rpm

2 創(chuàng)建安裝目錄

cd /opt/
mkdir postgresql
cd postgresql

3 安裝

rpm -ivh libicu-50.2-4.el7_7.x86_64.rpm --force --nodeps
rpm -ivh postgresql96-libs-9.6.20-1PGDG.rhel7.x86_64.rpm --force --nodeps
rpm -ivh postgresql96-9.6.20-1PGDG.rhel7.x86_64.rpm --force --nodeps
rpm -ivh postgresql96-server-9.6.20-1PGDG.rhel7.x86_64.rpm --force --nodeps

4 配置

# 初始化數(shù)據(jù)庫(kù) #
/usr/pgsql-9.6/bin/postgresql96-setup initdb
# 開(kāi)機(jī)啟動(dòng)#
systemctl enable postgresql-9.6
# 啟動(dòng)pg #
systemctl start postgresql-9.6

5 修改pg配置文件

修改postgresql.conf

vi /var/lib/pgsql/9.6/data/postgresql.conf

修改pg_hba.conf (根據(jù)實(shí)際需求限制訪問(wèn)ip)

vi /var/lib/pgsql/9.6/data/pg_hba.conf

6 重啟postgresql

systemctl restart postgresql-9.6

7 常用命令postgresql

啟動(dòng):

systemctl start postgresql-9.6

停止:

systemctl stop postgresql-9.6

重啟:

systemctl restart postgresql-9.6

8 測(cè)試是否安裝成功,啟動(dòng)成功。

切換系統(tǒng)“postgres”用戶

su - postgres
#輸入密碼,默認(rèn)沒(méi)有密碼
設(shè)置的密碼
#輸入psql
psql
#如果沒(méi)有修改過(guò)postgres密碼,修改postgres密碼, 就可以直接用工具連接pg數(shù)據(jù)庫(kù)了。
ALTER USER postgres WITH PASSWORD '123456';
?著作權(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)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

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

  • 介紹 PostgreSQL是加州大學(xué)伯克利分校計(jì)算機(jī)系開(kāi)發(fā)的對(duì)象關(guān)系型數(shù)據(jù)庫(kù)管理系統(tǒng),目前擁有活躍的開(kāi)源社區(qū)貢獻(xiàn),...
    小小的小帥閱讀 1,496評(píng)論 0 1
  • 一、PostgreSQL簡(jiǎn)介 PostgreSQL是一個(gè)功能強(qiáng)大的開(kāi)源對(duì)象關(guān)系數(shù)據(jù)庫(kù)管理系統(tǒng)(ORDBMS)。用...
    MaoCoo閱讀 727評(píng)論 0 0
  • 1、 yum install -y https://download.postgresql.org/pub/rep...
    昵稱(chēng)違規(guī)閱讀 1,330評(píng)論 0 0
  • 項(xiàng)目使用pg,整理個(gè)初級(jí)的安裝教程,簡(jiǎn)化實(shí)施。部分內(nèi)容參考來(lái)源:http://m.itdecent.cn/p...
    老肖閱讀 6,377評(píng)論 0 1
  • 獲取源碼 安裝PostgreSQL的方法有很多,我們可以使用centos下的包管理器安裝,也可以從官網(wǎng)下載二進(jìn)制壓...
    weigs閱讀 3,428評(píng)論 1 3

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