postgresql数据库免安装版安装到windows系统

发布时间:2026/7/24 10:55:56
postgresql数据库免安装版安装到windows系统 1.下载Postgresql数据库免安装包下载地址https://www.enterprisedb.com/download-postgresql-binaries我下载了目前最新版18.4我保存到了E盘并解压。目录结构以管理员权限运行cmd并进入到bin目录执行pg_ctl --help如果成功执行不报错并且输出如下则说明本机不缺少依赖包。如果出现报错提示缺少xxx请安装vc的运行组件后再次尝试。vc_redist.x86.vc2015.14.0.23026.exe下载链接https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads设置初始密码我计划将data目录设置到E:\pgsql18_datainitdb -D “E:\pgsql18_data” -E UTF-8 --localechs -U postgres -W输入你的密码后会进行一些初始化。初始化完成后data目录创建了这些文件和目录编辑数据库目录下pgsql18_data/pg_hba.conf新增一条授权允许通过远程主机不限制IP 通过加密密码的方式进行数据库访问。更改数据库服务端口编辑postgresql.conf 改成你想要的端口安装为windows服务安装服务pg_ctl register -D “E:\pgsql18_data” -N postgresql18-5433 -S auto -U “NT AUTHORITY\LocalService”卸载服务pg_ctl unregister -N postgresql18-5433客户端连接数据库用到的命令检测环境 pg_ctl --help 设置数据库路径和初始密码 initdb -D “E:\pgsql18_data” -E UTF-8 --localechs -U postgres -W 安装服务 pg_ctl register -D “E:\pgsql18_data” -N postgresql18-5433 -S auto -U “NT AUTHORITY\LocalService” 卸载服务 pg_ctl unregister -N postgresql18-5433