环境:Win7 64位
安装程序:postgresql-10.4-1-windows-x64.exe
1.打开https://www.postgresql.org/download/
选择Windows后,我选的是下载一个安装程序,也可以下载压缩包再自己配置,这个以后尝试下。
2.选择需要的版本和操作系统,我选了最新的10.4,操作系统是x86-64(这个页面加载了好久好久= =)
3.运行exe文件,→next
4.选择安装目录,→next
5.选择要装的插件,这里我默认全选了,→next
6.自动生成了一个data文件夹,→next
7.设置超级管理员密码,→next
8.设置端口,默认是5432,→next
9.选择区域,这里我选了简体中文,不知道后面会不会出现问题,先这样吧~(〃'▽'〃),→next
10.确认安装设置,没什么问题就next
11.Ready to install,→next
12.安装完成(如出现Problem running post-install step. Installation may not complete correctly.错误,可以参考https://blog.csdn.net/dubaoti7942/article/details/81163682)
13.修改环境变量
PGHOME: E:\postgreSQL(你的安装位置)
PGDATA: %PGHOME\data
PGHOST: localhost
PGLIB: %PGHOME\lib
PATH: 增加 ;%PGHOME\bin;
14.初始化并创建数据库。在cmd窗口,cd至E:\postgreSQL\bin,执行命令
initdb.exe -D E:\postgresql\data -E UTF-8 --locale=chs -U postgres -W
其中:
-D:指定数据库数据的存储目录
-E:指定编码格式
--locale:区域设置
-U:指定超级用户的用户名postgres
-W:为超级用户指定密码的提示
15.启动数据库
pg_ctl -D E:\postgresql\data -l logfile start
16.注册为系统服务
pg_ctl register -N PostgreSQL -D E:\postgresql\data
(此时我启动失败过,查看事件管理器后,发现有 锁文件 "postmaster.pid" 已经存在 错误,把bin文件夹下的postmaster.pid文件删除后就成功启动了)
最后,就可以用SQL shell或者cmd执行下面命令操作数据库了~
/home/hadoop/dw_etl/sys/odl/odl_jobhistory_sys.bash