1、初始化并创建数据库(一次即可)
initdb -D C:\Soft\PostgreSQL\10\data -E UTF-8 --locale=chs -U postgres -W
You can now start the database server using(启动数据库命令):
pg_ctl -D ^"C^:^\Soft^\PostgreSQL^\10^\data^" -l logfile start
--家里电脑pg 启动路径
C:/Users/computer/scoop/apps/postgresql/current/bin/pg_ctl -D ^"C^:^\Users^\computer^\scoop^\apps^\postgresql^\current^\data^" -l logfile start
2、配置环境变量的vbs脚本
on error resume next set sysenv=CreateObject("WScript.Shell").Environment("system") ‘系统环境变量的数组对象 Path = CreateObject("Scripting.FileSystemObject").GetFolder(".").Path ‘添加变量 sysenv("PGHOME")="C:\Soft\PostgreSQL\10" sysenv("PGHOST")="localhost" sysenv("Path")=sysenv("PGHOME")+"\bin;"+sysenv("Path") sysenv("PGLIB")=sysenv("PGHOME")+"\lib" sysenv("PGDATA")=sysenv("PGHOME")+"\data" wscript.echo "PostgreSQL环境变量安装成功!不需要重新启动计算机啊!"
3、Postgresql注册成windows 服务
>pg_ctl.exe register -N "pgsql" -D "C:\Soft\PostgreSQL\10\data"
原文地址:https://www.cnblogs.com/hzy168/p/10293459.html
时间: 2024-10-08 00:00:01