views:

68

answers:

2

Hi

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 " 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 :(

A: 

Escape your \ character with an extra \

\\home\\web\\sql\\file.sql
MindStalker
that doesn't work either ...
Goz
A: 

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""";
Goz