離線安裝PostgreSQL11.6

由於客戶最近有一臺CentOS7的虛擬機,可是沒有聯網,須要安裝離線安裝PostgreSQLsql

一、首先去官網下載離線安裝包

     https://www.postgresql.org/download/數據庫

 

 

 說明:能夠點擊相應系統下載,也能夠點擊左邊導航source下載tar.gzvim

 

 

 選擇網頁下端的服務器

  我這次安裝的是11.6的版本工具

 

 

 

 

 

 

 

 

 

下載完成後就有下面三個包post

二、PostgreSQL安裝包

postgresql11-libs-11.6-1PGDG.rhel7.x86_64.rpm測試

postgresql11-11.6-1PGDG.rhel7.x86_64.rpmspa

postgresql11-server-11.6-1PGDG.rhel7.x86_64.rpm.net

若是沒有 安裝libicu,同時須要下載libicu-50.2-3.el7.x86_64.rpm 。具體的下載地址,百度一下。3d

三、上傳pg包到/tmp

能夠上傳到本身新建的目錄,我這裏是上傳到服務器的tmp下

cd /tmp
rpm -ivh postgresql11-libs-11.6-1PGDG.rhel7.x86_64.rpm
rpm -ivh postgresql11-11.6-1PGDG.rhel7.x86_64.rpm
rpm -ivh postgresql11-server-11.6-1PGDG.rhel7.x86_64.rpm

   這裏安裝遇到依賴檢測失敗,請參考:進行配置

四、安裝完成後初始化數據庫並啓用開機自啓動

這裏須要 cd 到個根目錄下,剛剛實在tmp目錄下,否則會找不到路徑。

/usr/pgsql-11/bin/postgresql-11-setup initdb

systemctl enable postgresql-11
systemctl start postgresql-11

五、配置/etc/hosts

其實這部我沒有配置

 

六、最後添加主機ip和主機名

vim /var/lib/pgsql/11/data/postgresql.conf

 

 七、根據實際需求開放訪問ip

vim  /var/lib/pgsql/11/data/pg_hba.conf

  

八、重啓postgresql

systemctl restart postgresql-11

su - postgres
psql

建立數據庫用戶
create user postgres password ‘pg’;

賦予帳號權限
ALTER ROLE postgres SUPERUSER;

新建數據庫
create database postgres;
退出

  

使用連接工具進行測試

安裝具體參考:http://www.javashuo.com/article/p-yaoehkla-ns.html  https://www.jianshu.com/p/b4a759c2208f

相關文章
相關標籤/搜索