postgresql windows 开发环境搭建
admin
2023-05-27 10:21:19
0

一、软件需求

  1. Windows 7 旗舰版 sp1 X64

  2. ActivePerl-5.22.3.2204-MSWin32-x64-401627.exe

  3. diffutils-2.8.7-1.exe, 编译之后回归测试使用,需要手工添加bin路径到PATH

  4. visual studio ultimate 2013,VS2013_RTM_ULT_CHS.iso

  5. visual assist,代码格式化工具

  6. postgresql-9.6.2.tar.gz,pg源码

二、安装IDE工具

1.安装Perl

  下载ActivePerl-5.22.3.2204-MSWin32-x64-401627.exe,双击安装

   单击"next",选择"接受协议",

   单击"next",安装类型"Type",

   安装选项"Add Perl to the PATH environment variable","create Perl file extension association"

   单击"next",单击"install",单击"finish"

   添加 bin目录"C:\Perl64\bin",配置到系统环境变量PATH.

2.安装Windows 平台 diff工具,回归测试使用

    下载diffutils-2.8.7-1.exe安装包,双击安装

    单击"next",选择"接受协议",默认配置,单击"next",...,单击"install",单击"finish"

    把软件安装的bin目录"C:\Program Files (x86)\GnuWin32\bin",配置到系统环境变量PATH中.


 3.安装visual studio ultimate 2013

    下载VS2013_RTM_ULT_CHS.iso,并解压到VS2013_RTM_ULT_CHS目录,解压完成进入这个目录

    双击"vs_ultimate.exe"进行安装,提示IE 8 不兼容建议IE 10 ,单击"继续",

    选择"同意许可",单击"下一步"

    选择安装功能,只选择"用于C++的Microsoft基础类",单击"安装"

    安装成功后,单击"启动",程序界面加载完成,帮助->注册产品,输入产品序列号

4.安装visual assist

  双击"VA_X_Setup2001.exe",只选择"Microsoft visual studio 2013 RC",单击"install"

  单击"确定",安装成功

  5.获取postgresql源码

   解压postgresql-9.6.2.tar.gz到F 盘根目录

  6. 编译安装数据库

开始->所有程序->visual studio 2013->visual studio tools

  目录中双击"VS2013 x64 本机工具命令提示",打开visual studio 2013命令行窗口

   转到"F:\postgresql-9.6.2\src\tools\msvc"目录,

   1) 编译数据库

   执行perl build.pl DEBUG(DEBUG,代表调试模式,如果不加表示非调试模式)

    2) 回归测试,

 perl vcregress.pl check

   .............

test event_trigger            ... ok

test stats                    ... ok

============== shutting down postmaster               ==============

============== removing temporary instance            ==============


=======================

 All 167 tests passed.

=======================


  3) 安装数据库

F:\postgresql-9.6.2\src\tools\msvc>perl install.pl f:\pg962

Installing version 9.6 for debug in f:\pg962

Copying build output files......................................................

..........................................................................

Copying config files......

Copying Import libraries...

Copying contrib data files......................................................

................................................................................

...........................................................................

Copying Public headers......

Copying Libpq headers..

Copying Libpq internal headers..

Copying Internal headers...

Copying Server headers....

Copying Grammar header.

......................

Copying PL/pgSQL header.

复制了 63 个文件

复制了 1 个文件

复制了 78 个文件

复制了 33 个文件

复制了 9 个文件

复制了 1 个文件

复制了 48 个文件

复制了 6 个文件

复制了 2 个文件

复制了 7 个文件

复制了 13 个文件

复制了 1 个文件

复制了 19 个文件

复制了 25 个文件

复制了 21 个文件

复制了 41 个文件

复制了 2 个文件

复制了 10 个文件

复制了 5 个文件

复制了 14 个文件

复制了 7 个文件

复制了 34 个文件

复制了 50 个文件

复制了 6 个文件

复制了 7 个文件

复制了 77 个文件

Copying ECPG headers...............

Copying ECPG informix headers...

Copying timezone names..........

Copying timezone sets...

Copying BKI files...

Copying SQL files..

Copying Information schema data.

Generating conversion proc script...

Generating timezone files...

Generating tsearch script..................

Copying Stopword files..............

Copying Dictionaries sample files.........

Copying PL Extension files...

Installation complete.

F:\postgresql-9.6.2\src\tools\msvc>


4) 初始化数据库

F:\postgresql-9.6.2\src\tools\msvc>cd /d f:\pg962\bin

f:\pg962\bin>initdb.exe -D ../data

The files belonging to this database system will be owned by user "Administrator

".

This user must also own the server process.


The database cluster will be initialized with locale "Chinese (Simplified)_Peopl

e's Republic of China.936".

Encoding "GBK" implied by locale is not allowed as a server-side encoding.

The default database encoding will be set to "UTF8" instead.

initdb: could not find suitable text search configuration for locale "Chinese (S

implified)_People's Republic of China.936"

The default text search configuration will be set to "simple".


Data page checksums are disabled.


creating directory ../data ... ok

creating subdirectories ... ok

selecting default max_connections ... 100

selecting default shared_buffers ... 128MB

selecting dynamic shared memory implementation ... windows

creating configuration files ... ok

running bootstrap script ... ok

performing post-bootstrap initialization ... ok

syncing data to disk ... ok


WARNING: enabling "trust" authentication for local connections

You can change this by editing pg_hba.conf or using the option -A, or

--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:


    "pg_ctl" -D "../data" -l logfile start

f:\pg962\bin>


5) 启动数据库


f:\pg962\bin>pg_ctl.exe -D "../data" -l logfile start

server starting


pg数据库已经编译安装并运行起来了,可以正常使用.

执行select version();查看下版本


f:\pg962\bin>psql postgres

psql (9.6.2)

Type "help" for help.

postgres=# \du

                                     List of roles

   Role name   |                         Attributes                         | Me

mber of

---------------+------------------------------------------------------------+---

--------

 Administrator | Superuser, Create role, Create DB, Replication, Bypass RLS | {}


postgres=# select version();

                           version

-------------------------------------------------------------

 PostgreSQL 9.6.2, compiled by Visual C++ build 1800, 64-bit

(1 row)

postgres=#



问题解答:


装上后再跑执行 perl build.pl报如下错误: Unable to determine Visual Studio version: The nmake version could not be determined. at src/tools/msvc/Mkvcbuild.pm line 86.  这是perl脚本中不能正常识别vs版本造成,该问题历史悠久,不知道pg为什么不修复,要修正很简单,打开msvc目录中 VSObjectFactory.pm文件,把该文件最下面的 DetermineVisualStudioVersion 函数中  if ($output =~ /(\d+)\.(\d+)\.\d+(\.\d+)?$/m) 这行改成if ($output =~ /(\d+)\.(\d+)\.\d+(\.\d+).*$/m)  ,实际就是将 ? 改成.* 即可。

相关内容

热门资讯

陕西柞水遭遇大暴雨,五千余户群... 8月5日7时至15时,陕西省商洛市柞水县出现大到暴雨、局地大暴雨,杏坪社区地质站最大降雨量135.4...
伊朗与阿曼会谈最新细节曝光 美国有线电视新闻网(CNN)8月5日报道,伊朗和阿曼将敲定一项关于通过霍尔木兹海峡进行商业航运的框架...
大科学装置建设全面提速 创新成... 央视网消息(新闻联播):重大科技基础设施是建设科技强国的利器。今年以来,我国大科学装置建设全面提速,...
贝塔创新科技观察算力公有化趋势... 从公有云到公有算力网络:AI基础设施进入弹性调度时代 过去几年,市场更关注大模型参数、算法能力和应...
活力中国调研行丨激活创新源 合... 新华社合肥8月5日电 题:激活创新源 合肥大健康科研成果加速产业化 新华社记者高亢、张紫赟 近日,“...
凤凰连线:为何伊朗称“即使与阿... 据凤凰卫视报道,伊朗知情人士当地时间周三透露称,伊朗与阿曼就霍尔木兹海峡船舶通行安排,可能达成协议,...
伊朗称与阿曼就霍尔木兹海峡航运... 据凤凰卫视报道,伊朗外交部发言人巴加埃5日表示,伊朗与阿曼已就霍尔木兹海峡拟定航道的地理坐标达成一致...
予非知识图谱大模型完成生成式人... 近日,山东省网信办正式公布生成式人工智能服务备案名录,潍坊华创信息技术有限公司自主研发的“予非知识图...
学习语丨人工智能应该是造福全人... 近日,习近平总书记向2025世界智能产业博览会致贺信,指出:“人工智能应该是造福全人类的国际公共产品...
2026年交易全链路可追溯的智... 2026-08-05 12:10:48 作者:狼叫兽 2026年被视作智能体支付规模化落地的关键之年...