Goz
Goz

Reputation: 62323

Calling MySQL from inside an Inno Setup project

I'm writing an installer for some software that uses MySQL. I'm trying to run a .sql script to set up the database on install. Alas I'm having big problems getting it to execute at the moment.

The issue seems to arise from the fact that the moment you put a path to the .sql file inside the --execute="SOURCE <path to .sql file>" command everything falls apart. I've also tried piping it in and it doesn't work. If I run it form the command line, however, I get back errors around it not being able to handle the "\" in there.

Is there any way I can do this? Its driving me mad I've spent a day on it already :(

Upvotes: 2

Views: 3646

Answers (2)

Goz
Goz

Reputation: 62323

Ok Well I've got it. Basically it works if you are calling mysql from the directory that the sql file is in. ie --execute="SOURCE temp.sql". Under innosetup this can be done by setting the path to the .sql as the WorkingDir as follows:

Filename: "{pf32}\MYSQL\MySQLServer\Bin\MySQL.exe"; BeforeInstall: MakeQuery; AfterInstall: DeleteQuery; WorkingDir: "{app}\Database"; Flags: waituntilterminated; Parameters: "-u root --password=<password>  --database=<db> --execute=""SOURCE temp.sql""";

Upvotes: 2

MindStalker
MindStalker

Reputation: 14864

Escape your \ character with an extra \

\\home\\web\\sql\\file.sql

Upvotes: 1

Related Questions