RedHat 7 安裝PostgreSQL 10.5


系統環境

Redhat:

    Version: 7.4.1708

Architecture: x86_64

Address:

            10.127.1.11

        User:

            root

        Uassword:

            redhat

Postgresql:

version: 10

platform: Redhat Enterprise Linux 7

architecture: x86_64

Address:

            10.127.1.11

        User:

            postgres

        Uassword:

            redhat

 

具體安裝

  1. Install the repository RPM:

    yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-redhat10-10-2.noarch.rpm

  2. Install the client packages:

    yum install postgresql10

  3. Optionally install the server packages:

    yum install postgresql10-server

  4. Optionally initialize the database and enable automatic start:

    /usr/pgsql-10/bin/postgresql-10-setup initdb
    systemctl enable postgresql-10
    systemctl start postgresql-10

 

遠程連接

  1. Modify user password

    su - postgres 

    切換用戶,執行后提示符會變為 '-bash-4.2$'

    psql -U postgres

    登錄數據庫,執行后提示符變為 'postgres=#'

    ALTER USER postgres WITH PASSWORD 'postgres';   

    設置postgres用戶密碼為postgres

    \q 

    退出數據庫

  2. Open remote access

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

    修改#listen_addresses = 'localhost'

    listen_addresses='*'

    當然,此處'*'也可以改為任何你想開放的服務器IP

  3. Trusted remote connection

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

        修改如下內容,信任指定服務器連接

        # IPv4 local connections:

        host    all            all      127.0.0.1/32      ident

        host all all 0.0.0.0/0 (需要連接的服務器IP md5

  4. Reboot service

    systemctl restart postgresql-10

     

     

     

  5. Test connection

 

參考網子

https://www.postgresql.org/download/


免責聲明!

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



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