CentOS離線安裝PostgreSQL12
一、下載資源包
-
下載地址
https://www.postgresql.org/download/
-
拉到最下邊點擊direct download
-
選擇自己適用的版本(根據自己的系統)
-
點擊進入
-
下載下邊四個檔案
二、進行安裝、啟動
-
? 將剛才下載的四個檔案放到自己的服務器上,然后執行以下命令
rpm -ivh postgresql12-libs-12.10-1PGDG.rhel7.x86_64.rpm rpm -ivh postgresql12-contrib-12.10-1PGDG.rhel7.x86_64.rpm rpm -ivh postgresql12-12.10-1PGDG.rhel7.x86_64.rpm rpm -ivh postgresql12-server-12.10-1PGDG.rhel7.x86_64.rpm -
初始化資料庫
/usr/pgsql-12/bin/postgresql-12-setup initdb -
啟動服務
systemctl start postgresql-12
三、配置服務
-
允許其他ip訪問和埠號設定
vi /var/lib/pgsql/12/data/postgresql.conf? listen_addresses = '*' 表示監聽所有的ip資訊
? port = 5432 表示服務的埠,可以自定義為其他埠
-
修改允許訪問的IP(以下配置允許所有的IP訪問)
| TYPE | DATABASE | USER | ADDRESS | METHOD |
|---|---|---|---|---|
| host | all | all | 0.0.0.0/0 | md5 |
以上修改完成,需要重啟服務才生效
重啟服務
systemctl restart postgresql-12
四、創建用戶及資料庫
-
切換到postgres用戶
su - postgres psql -p 5432 -
創建資料庫用戶名
create user test with password '123456'; -
創建資料庫
create database testdb; -
將testdb授權給test用戶
?
grant all privileges on database testdb to test;
?
五、基本的安裝配置已完成
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/457956.html
標籤:其他
上一篇:按多個標準對資訊進行分組?
下一篇:mysql范式
