I leave my version of mysql installation here using inno setup, in which you can configure the port and service name for version 5.6 using customPage. I have not tried it with other versions. This solution was found thanks to other contributions.
[Registry] Root: HKLM; Subkey: "SOFTWARE\MySoftware\G2Database"; ValueType: string; ValueName: Port; ValueData: {code:GetPort}; Flags: createvalueifdoesntexist uninsdeletekeyifempty uninsdeletevalue Root: HKLM; Subkey: "SOFTWARE\MySoftware\G2Database"; ValueType: string; ValueName: ServiceName; ValueData: {code:GetServiceName}; Flags: createvalueifdoesntexist uninsdeletekeyifempty uninsdeletevalue We create 2 registers to save the data of Port and service name
[FILES] Source: "{#InstallersDir}MysqlServer\server_5631_win32.msi"; DestDir: "{tmp}"; Flags: ignoreversion nocompression; Tasks: Mysql Source: "{#InstallersDir}MysqlServer\script.txt"; DestDir: "{app}\mysql\bin"; Flags: ignoreversion nocompression ; Tasks: Mysql Source: "{#InstallersDir}MysqlServer\users.bat"; DestDir: "{app}\mysql\bin"; Flags: ignoreversion nocompression ; Tasks: Mysql [CODE] var lblPort: TLabel; lblServiceName: TLabel; ePort: TEdit; eServiceName: TEdit; procedure frmDBSettingsReg_Activate(Page: TWizardPage); begin end; function frmDBSettingsReg_ShouldSkipPage(Page: TWizardPage): Boolean; begin Result := False; end; function frmDBSettingsReg_BackButtonClick(Page: TWizardPage): Boolean; begin Result := True; end; function frmDBSettingsReg_NextButtonClick(Page: TWizardPage): Boolean; begin Result := True; end; procedure frmDBSettingsReg_CancelButtonClick(Page: TWizardPage; var Cancel, Confirm: Boolean); begin end; function frmDBSettingsReg_CreatePage(PreviousPageId: Integer): Integer; var Page: TWizardPage; begin Page := CreateCustomPage( PreviousPageId, ExpandConstant('{cm:AdvancedSettings}'), ExpandConstant('{cm:AdvancedDescription}') ); { lblPort } lblPort := TLabel.Create(Page); with lblPort do begin Parent := Page.Surface; Left := ScaleX(24); Top := ScaleY(30); Width := ScaleX(35); Height := ScaleY(13); Caption := ExpandConstant('{cm:Port}'); end; { lblServiceName } lblServiceName := TLabel.Create(Page); with lblServiceName do begin Parent := Page.Surface; Left := ScaleX(24); Top := ScaleY(60); Width := ScaleX(52); Height := ScaleY(13); Caption := ExpandConstant('{cm:ServiceName}') ; end; { ePort } ePort := TEdit.Create(Page); with ePort do begin Parent := Page.Surface; Left := ScaleX(130); Top := ScaleY(27); Width := ScaleX(185); Height := ScaleY(21); Text := '3306'; TabOrder := 0; end; { eServiceName } eServiceName := TEdit.Create(Page); with eServiceName do begin Parent := Page.Surface; Left := ScaleX(130); Top := ScaleY(56); Width := ScaleX(185); Height := ScaleY(21); Text := 'G2Database'; TabOrder := 1; end; with Page do begin OnActivate := @frmDBSettingsReg_Activate; OnShouldSkipPage := @frmDBSettingsReg_ShouldSkipPage; OnBackButtonClick := @frmDBSettingsReg_BackButtonClick; OnNextButtonClick := @frmDBSettingsReg_NextButtonClick; OnCancelButtonClick := @frmDBSettingsReg_CancelButtonClick; end; Result := Page.ID; end; function GetPort(param: String): String; begin Result := Trim(ePort.Text); end; function GetServiceName(param: String): String; begin Result := Trim(eServiceName.Text); end; ''' We create a new CustomPage to let user set Port and Servicename {cm:X} means CustomMessage just has to put your own text and remove ExpandConstant In my case I wanted to skip the MySQL configuration in case you don't mark the task ''' function ShouldSkipPage(curPageId:Integer):Boolean; begin if curPageID <> 100 then //Need to check if in your case is same ID Result := false else if ((curPageID = 100) and not WizardIsTaskSelected('Mysql')) then Result := true end; [RUN] ;Install MySQL Filename: msiexec.exe; Parameters:"/i""{tmp}\server_5631_win32.msi"" /qn INSTALLDIR=""YOUR RUTE"" DATADIR=""YOUR RUTE"" PORT=""{code:GetPort}"" "; WorkingDir:{app}; StatusMsg:"{cm:waitDatabase}"; Flags: runhidden; Tasks: Mysql ;Install Service Filename: YOUR RUTE\mysqld.exe; Parameters:"--install {code:GetServiceName} --port=""{code:GetPort}"""; WorkingDir:{app}; Flags: runhidden; Tasks: Mysql ;Start Service Filename: net.exe; Parameters: start {code:GetServiceName}; WorkingDir:{app}; StatusMsg:{cm:startDatabase}; Flags: runhidden; Tasks: Mysql ;Open Firewall Port Filename: netsh; Parameters: firewall add portopening TCP {code:GetPort} {code:GetServiceName}; Flags: runhidden; StatusMsg:{cm:configureDatabase}; Tasks: Mysql ;Create Custom users Filename: {app}\mysql\bin\users.bat; Parameters:" {code:MySQLPath} {code:FormatRute} {code:GetPort}"; StatusMsg:{cm:configureDatabase};Flags: runhidden;Tasks: Mysql ''' Here comes Script.txt and Users.bat and Aux Functions for them ''' Script.txt use mysql; update user set password=PASSWORD("root") where user='root'; CREATE USER 'myUser'@'%' IDENTIFIED BY 'myUser'; GRANT ALL PRIVILEGES ON * . * TO 'myUser'@'%'; CREATE USER 'myUser'@'localhost' IDENTIFIED BY 'myUser'; GRANT ALL PRIVILEGES ON * . * TO 'myUser'@'localhost'; FLUSH PRIVILEGES; Users.bat :: Move to mysql dir cd %1 :: Start session with user root -Port and execute script call "mysql.exe" -u root -P %3 < %2/script.txt //All this functions will go at CODE section function MySQLPath(Param:String):String; var Path: string; begin Path := ExpandConstant('{pf}\MySQL\MySQLServer5.6\bin'); Result := FileSearch ('mysqld.exe',Path ); StringChangeEx(Result, 'mysqld.exe', '', True); Result := '"' + Result + '"'; end; function FormatRute(Param:String):String; begin Result := ExpandConstant('{app}\mysql\bin'); Result := '"' + Result + '"' end;
source share