Linux安裝Postgresql

一 、yum安裝

二、離線安裝

1 安裝包和依賴下載

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ù)庫 #
/usr/pgsql-9.6/bin/postgresql96-setup initdb
# 開機啟動#
systemctl enable postgresql-9.6
# 啟動pg #
systemctl start postgresql-9.6

5 修改pg配置文件

修改postgresql.conf

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

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

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

6 重啟postgresql

systemctl restart postgresql-9.6

7 常用命令postgresql

啟動:

systemctl start postgresql-9.6

停止:

systemctl stop postgresql-9.6

重啟:

systemctl restart postgresql-9.6

8 測試是否安裝成功,啟動成功。

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

su - postgres
#輸入密碼,默認沒有密碼
設(shè)置的密碼
#輸入psql
psql
#如果沒有修改過postgres密碼,修改postgres密碼, 就可以直接用工具連接pg數(shù)據(jù)庫了。
ALTER USER postgres WITH PASSWORD '123456';
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

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

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

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