Linux下使用yum安装PostgreSQL

背景:

系统:CentOS7 x64   虚拟机环境

说明:详细参见官网安装说明https://www.postgresql.org/download/linux/redhat/

使用yum安装PostgreSQL,对应安装的版本如图所示;

  1. 安装指令很简单: yum install postgresql-server
  2. 安装完之后,还需要执行下 数据库初始化指令以及一些配置,参见官网截图:
    1. 初始化数据库:postgresql-setup initdb
    2. 允许开机启动数据库服务:systemctl enable postgresql.service
    3. 启动数据库服务:systemctl start postgresql.service

以上是官网上给的安装指南,下文是小编在安装过程中浏览其他博客的时候,加入的配置

  1. 切换用户:su - postgres
  2. 开启远程服务:
    1. 编辑配置文件:vim /var/lib/pgsql/data/postgresql.conf
    2. 修改内容 #listen_addresses = 'localhost'  为  listen_addresses='*'  (将这一行取消注释,如图所示)
    3. 保存:wq
  3. 信任远程服务:
    1. 编辑配置文件:vim /var/lib/pgsql/data/pg_hba.conf 
    2. 添加内容:如图所示
      # IPv4 local connections:
      host    all            all      127.0.0.1/32      ident
      host    all            all      192.168.1.1/32(需要连接的服务器IP)  trust
    3. 保存:wq
  4. 重启服务:systemctl restart postgresql.service
发布了69 篇原创文章 · 获赞 3 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/Min_Monk/article/details/100161600