3
votes

My application uses MySQL Server. Elaborated in inno setup script that does the following:

In the [code]

  1. Install MySQL Server (Ok)
  2. Install MySQL ODBC Connector (Ok)
  3. Configure the MySQL Server (Ok)
  4. Starts a service MySQL on Windows (Ok)
  5. Installs the application (Ok)

In the [run]

  1. Uses a batch file to enter User and Password in the User table MySQL (Ok)
  2. Uses a batch file to create the database application (Ok)
  3. Starts the application (Ok)

The script worked fine, however I wanted the items 1 and 2 of section [run] were also carried out in the [code] thus:

In the [code]

  1. Install MySQL Server (Ok)
  2. Install MySQL ODBC Connector (Ok)
  3. Configure the MySQL Server (Ok)
  4. Starts a service MySQL on Windows (Ok)
  5. Uses a batch file to enter User and Password in the User table MySQL (Error)
  6. Uses a batch file to create the database application (Error)
  7. Installs the application (Ok)

In the [run]

  1. Starts the application (Ok)

But the second scheme is an error in the inclusion of new user and password and the creation of the database. In the [run] this does not occur.

The code I used in [code] to insert User and Password is as follows:

if (CurStep = ssInstall) then
begin WizardForm.ProgressGauge.Style: = npbstMarquee; WizardForm.StatusLabel.Caption: = 'Starting service MySQL on Windows. This may take a few minutes ... ';
if not Exec (ExpandConstant ('{pf} \ MySQL \ MySQL Server 5.5 \ bin \ mysqld.exe'), 'mysql-u root GRANT ALL PRIVILEGES ON *. * TO myusername @ localhost IDENTIFIED BY mypassword WITH GRANT OPTION;' '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then
MsgBox ('The MySQL service failed. Code:' + IntToStr (ResultCode) mbInformation, MB_OK);
WizardForm.ProgressGauge.Style: = npbstNormal; WizardForm.StatusLabel.Caption: ='';
end;
1

1 Answers

0
votes

MySQL client mysql.exe takes SQL commands using the param -e

Command should look like this

mysql -uroot -e"GRANT ALL PRIVILEGES ON *.* TO 'myusername'@'localhost' IDENTIFIED BY 'mypassword' WITH GRANT OPTION"

Also don't forget to set a root password