使用NSIS安装Postgresql [英] Installation of postgresql with NSIS

查看:99
本文介绍了使用NSIS安装Postgresql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将使用NSIS安装程序安装postgresql,但我不知道如何。

I would install postgresql with the NSIS installer, but I don't know how.

您能帮我吗?

我找到了此代码

outfile "C:\project-open\installer\install_postgres.exe"
Name "Install PostgreSQL"

!include Registry.nsh
!include LogicLib.nsh
!include MultiUser.nsh
!include Sections.nsh
!include MUI2.nsh`

!define TARGET c:\project-open

Function .onInit
   StrCpy $INSTDIR "c:\project-open"
FunctionEnd

section
    UserMgr::CreateAccountEx "postgres" "*******" "PostgreSQL" "PostgreSQL Database      User" "Database user created by ]po[ installer" "UF_PASSWD_NOTREQD|UF_DONT_EXPIRE_PASSWD"
pop $R0
DetailPrint "After creating account: result=$R0"`

UserMgr::AddPrivilege "postgres" "SeBatchLogonRight"
pop $R0
DetailPrint "SeBatchLogonRight: result=$R0"

UserMgr::AddPrivilege "postgres" "SeServiceLogonRight"
pop $R0
DetailPrint "SeServiceLogonRight: result=$R0"

nsExec::ExecToLog '"$INSTDIR\pgsql\bin\initdb.exe" --username=postgres --locale=C --encoding=UTF8 -D "$INSTDIR\pgsql\data"'
pop $R0
DetailPrint "After initializing database: result=$R0"

nsExec::ExecToLog 'sc create postgresql-9.2 binpath= "c:\project-open\pgsql\bin\pg_ctl.exe runservice -N postgresql-9.2 -D c:/project-open/pgsql/data -w" DisplayName= "PostgreSQL 9.2" start= "demand" type= own obj= ".\postgres" password= "******" '
pop $R0
DetailPrint "After registering the service: result=$R0"sectionEnd`

但是我有 UserMgr :: CreateAccountEx 的问题,但是我已经导入了所需的所有文件。

but I have a problem with UserMgr::CreateAccountEx but I've imported all files required.

推荐答案

您需要做的就是创建数据目录:

All you need to do is create a data dir:

initdb -D %PROGRAMDATA%\MyApp\data

然后安装PostgreSQL配置文件和 pg_hba.conf 或对生成的文件进行必要的编辑由 initdb %PROGRAMDATA%\MyApp\data\postgresql.conf %PROGRAMDATA%\MyApp\data\pg_hba.conf

then install your PostgreSQL config file and pg_hba.conf or make any required edits to the files generated automatically by initdb at %PROGRAMDATA%\MyApp\data\postgresql.conf and %PROGRAMDATA%\MyApp\data\pg_hba.conf.

然后:

pg_ctl register -D %PROGRAMDATA%\MyApp\data -S auto -N postgres-MyApp -U NETWORKSERVICE

net start postgres-MyApp

不要使用默认端口5432。 -default端口,不会与任何现有的或将来的Pos​​tgreSQL安装冲突。另外,请勿使用 postgresql-9.2 之类的标准服务名称。

Please do not use the default port 5432. Run on a non-default port that won't conflict with any existing or future PostgreSQL install. Also, do not use the "standard" service names like postgresql-9.2.

(NSIS可能会提供命令启动服务,而不是使用 net start 。如果这样做,请使用相应的NSIS命令。

(NSIS may offer a command to start a service, instead of using net start. If it does, use the appropriate NSIS command).

请注意,%PROGRAMDATA%仅为Windows Vista和更高版本定义(它指向%SYSTEMDRIVE%\ProgramData 默认)。您可以在Windows XP上使用%ALLUSERSPROFILE%,但实际上,谁在乎XP?

Note that %PROGRAMDATA% is only defined for Windows Vista and higher (where it points to %SYSTEMDRIVE%\ProgramData by default). You can use %ALLUSERSPROFILE% on Windows XP, but really, who cares about XP now?

我个人建议与WiX一起使用MSI安装程序。

Personally, I suggest using MSI installers with WiX.

这篇关于使用NSIS安装Postgresql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆