Windows Server 2012 R2 上安装PostgreSQL 13

第一步 安装Windows Server 2012 升级补丁

按照顺序安装

  • Windows8.1-KB2939087-x64.msu
  • Windows8.1-KB2975061-x64.msu
  • Windows8.1-KB2919355-x64.msu
  • Windows8.1-KB2999226-x64.msu

第二步 安装MicroSoft VC++ 2015-2019 Redistributable 环境

第三步 安装postgresql-13.2-1-windows-x64

第四步 在服务器上创建非管理员账号(注意命令行用管理员身份)

执行命令 net user postgres password /add 创建postgres账号
执行命令 runas /user:postgres cmd.exe 以postgres账号运行cmd窗口

第五步 以管理员账号注册postgres服务


initdb.exe -D "D:Program FilesPostgreSQL13data" -E UTF-8 --locale=chs -U postgres -W

第六步 初始化数据库及服务启动

  • 以系统管理员运行命令 initdb.exe -D "D:/PostgreSQL/13/data" -E UTF-8 --locale=chs -U postgres -W


     
    初始化数据
  • 设置系统环境变量PGDATA


     
    系统环境变量
  • 以系统管理员运行命令运行 pg_ctl.exe start 启动服务


     
    启动服务

第七步 允许远程访问postgresql

  • 找到postgresql.conf文件,注意安装路径
    D:Program Files (x86)PostgreSQL9.3data
  • 打开该文件,注意以下内容,确认为下面内容后,进行下一步
    listen_addresses = '*'
  • 打开pg_hba.conf文件,注意以下内容
    host all all 0.0.0.0/32 trust
  • 在Windows的服务中重新启动postgre服务
原文地址:https://www.cnblogs.com/zhyp/p/14718197.html