centos7安裝PostgreSQL


1.PostgresSQL安裝

1.安裝rpm文件
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
2.安裝客服端
yum install postgressql10
3.安裝服務端
yum install postgresql10-server
4.初始化
/usr/pgsql-10/bin/postgresql-10-setup initdb
5.設置自動啟動並且啟動postgressql服務
systemctl enable postgresql-10
systemctl start postgresql-10

2.創建用戶和數據庫

1.使用postgres用戶登錄(PostgresSQL安裝后會自動創建postgres用戶,無密碼)
su - postgres
2.登錄到postgresql數據庫
psql
3.創建用戶
create user test with password 'cps123';
4.創建數據庫
create database test_db owner test ;
5.授權訪問
grant all privileges on database test_db to test

3.遠程訪問

1、修改/var/lib/pgsql/10/data/postgresql.conf文件,取消 listen_addresses 的注釋,將參數值改為“*”
2、修改/var/lib/pgsql/10/data/pg_hba.conf文件,添加
host all all 0.0.0.0/0 md5
3、切換到root用戶,重啟postgresql服務
systemctl restart postgresql-10.service


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM