码迷,mamicode.com
首页 > 数据库 > 详细

RedHat 7 安装PostgreSQL 10.5

时间:2018-11-01 21:02:41      阅读:293      评论:0      收藏:0      [点我收藏+]

标签:分享   boot   gre   var   inux   lin   信任   local   远程   

系统环境

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 ‘redhat‘?

    设置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/

RedHat 7 安装PostgreSQL 10.5

标签:分享   boot   gre   var   inux   lin   信任   local   远程   

原文地址:https://www.cnblogs.com/XiaoGuanYu/p/9892321.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!