在windows安装和配置postgre
Easul Lv6

相关链接及下载

下载postgre,选择所需的版本
其他相关连接

软件包的安装及配置

先解压postgre,然后在其根目录下创建datarun_logs目录(数据库的数据存储目录和运行时目录)
然后在PATH中添加postgre的环境变量

数据库初始化

SHIFT + 鼠标右键打开管理员cmd,进行如下操作

折叠代码块BASH 复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 初始化数据库数据
# -U, --username=NAME 数据库超级用户名
# -W, --pwprompt 对于新的超级用户提示输入口令
# --locale=C 为新数据库设置默认语言环境
# -E, --encoding=ENCODING 为新数据库设置默认编码
# -D, --pgdata=DATADIR 当前数据库簇的位置
initdb.exe -U postgres -W --locale=C -D "postgre目录\data" -E UTF8
# 然后需要输入两次用户密码,可以还是postgres
# 启动postgre
# -D:指定数据库存放目录
# -l:指定本次日志存放位置
pg_ctl.exe -D "postgre目录\data" -l "postgre目录\run_logs\logfile.log" start
# 停止postgre
pg_ctl.exe -D "postgre目录\data" -l "postgre目录\run_logs\logfile.log" stop
# 重启postgre
pg_ctl.exe -D "postgre目录\data" -l "postgre目录\run_logs\logfile.log" restart
# 命令行不要关,关了服务就关了
# 然后登录postgre
# 也可以用pgadmin或dbeaver连接
psql -U postgres

# 将postgre注册为系统服务
# 先关闭刚刚启动的postgre
pg_ctl.exe -D "postgre目录\data" -l "postgre目录\run_logs\logfile.log" stop
# 删除postgre原本可能存在的服务
pg_ctl.exe unregister -N postgresql
# 增加一个postgre的服务
# -N指定的是服务名称
pg_ctl.exe register -N "pgsql" -D "postgre目录/data"
# 取消开机自启动可以在服务中禁用自启动即可
# 启动postgre服务
net start pgsql
# 停止postgre服务
net stop pgsql

postgre安装
postgre创建服务

 评论
来发评论吧~
Powered By Valine
v1.5.2