PostgreSQL安装

1、下载PostgreSQL

官网地址 https://www.postgresql.org/

image-20230216184949697

2、解压到要安装的路径

image-20230216190050880

在与bin的同级目录新建一个data文件夹

image-20230216190136403

3、初始化数据库,进入bin目录并执行初始化命令

初始化DB命令: initdb.exe -D  D:\postgresql\data  -E UTF-8 --locale=chs
-U postgres -W 注:
-D :指定数据库簇的存储目录D:\postgresql\data
-E :指定DB的超级用户的用户名postgres –locale:关于区域设置(chinese-simplified-china)
-U :默认编码格式chs
-W :为超级用户指定密码的提示

输入指令会提示要输入新的密码

image-20230216190728776

出现如下提示,右键data-->属性-->将user给与修改权限

image-20230216190931698 image-20230216191712643

成功

image-20230216191602284

4、启动数据库

pg_ctl -D D:\postgresql\data -l logfile start

image-20230216192415154

5、注册为系统服务

pg_ctl register -N 服务名 -D D:\postgres\pgsql\data

image-20230216192838568

win+r 输入service.msc,查看是否注册成功

image-20230216192936608