Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
301 views
in Technique[技术] by (71.8m points)

java - How to do a silent install of mysql in inno setup?

I would create a setup program for my java application. It uses a mysql database so the installation of my program must include the installation of mysql server 5.5, the configuration of server and loading of my database. I use Inno set up to do this but i found some problems. I found this code but it is a little old

Filename: msiexec; Parameters: "/i mysql-5.5.11-win32.msi /qn INSTALLDIR=""C:mysql"""; WorkingDir: C:UsersGabrieleDesktopsetup; StatusMsg: Sto installando Mysql 5.5.11;  Flags: runhidden

Filename: C:mysqlinmysqld-nt.exe; Parameters: --install; WorkingDir: C:mysqlin; StatusMsg: Sto installando il Servizio MySQL; Description: Installing MySQL Service; Flags: runhidden

Filename: net.exe; Parameters: start mysql; StatusMsg: Sto Avviando il Servizio MySQL; Description: Avvio Servizio MySQL; Flags: runhidden


Filename: C:mysqlinmysql.exe; Parameters: "-e ""insert into mysql.user(host,user,password) values ('localhost','root', PASSWORD('emmaus');"" -u root"; WorkingDir: {tmp}; StatusMsg: Configurazione del Server della Base di Dati; Flags: runhidden

Filename: C:mysqlinmysql.exe; Parameters: "-u root -h localhost -e ""create database ata";

Filename: C:mysqlinmysql.exe; Parameters: "-e ""grant all privileges on ata.* to ata;"" -u root"; WorkingDir: {tmp}; StatusMsg: Configurazione Server Base di Dati; Flags: runhidden


Filename: C:mysqlinmysql.exe; Parameters: "-e ""flush privileges;"" -u root"; WorkingDir: {tmp}; StatusMsg: Configurazione Server Base di Dati; Flags: runhidden


Filename: C:mysqlinmysql.exe; Parameters: "-u root -h localhost -e ""use ata; source ata.sql;"; WorkingDir: {tmp}; StatusMsg: Caricamento base di dati; Flags: runhidden  

when i debug it generates an error after the first statement. can not find the specified program in the second instruction. I tried to use mysqld instead of mysqld-nt but nothing changes

Can someone help me??

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
[Files]
Source: "J:mysql-5.5.11-win32.msi"; DestDir: "{tmp}"; Flags: nocompression dontcopy

[Run]
Filename: "{reg:HKLMSOFTWAREMySQL ABMySQL Server 5.5,Location}inmysqld.exe"; 
  Parameters: "--install"; WorkingDir: "{reg:HKLMSOFTWAREMySQL ABMySQL Server 5.5,Location}in"; 
  StatusMsg: "Sto installando il Servizio MySQL"; 
  Description: "Installing MySQL Service"; 
  Flags: runhidden; Check: MySQL_Is
;//and the rest of commands

[Code]
function MySQL_Is(): Boolean;
var
iResultCode: Integer;
begin
  Result := true;
  if (not RegKeyExists(HKLM, 'SOFTWAREMySQL ABMySQL Server 5.5')) or 
   (not FileExists(ExpandConstant('{reg:HKLMSOFTWAREMySQL ABMySQL Server 5.5,Location}inmysql.exe'))) 
  then begin
     ExtractTemporaryFile('mysql-5.5.11-win32.msi');
     Exec('msiexec.exe', '/i mysql-5.5.11-win32.msi /qn INSTALLDIR="C:mysql"', 
      ExpandConstant('{tmp}'), SW_HIDE, ewWaitUntilTerminated, iResultCode);
         if not FileExists(ExpandConstant('{reg:HKLMSOFTWAREMySQL ABMySQL Server 5.5,Location}inmysql.exe')) then begin
            MsgBox('Something went wrong! Installation should be terminated', 
              mbInformation, MB_OK);
            Result := false;
         end;
  end;
end;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...