Calling MySQL from inside an Inno Setup project

2019-04-02 10:49发布

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

2条回答
三岁会撩人
2楼-- · 2019-04-02 11:04

Escape your \ character with an extra \

\\home\\web\\sql\\file.sql
查看更多
啃猪蹄的小仙女
3楼-- · 2019-04-02 11:23

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""";
查看更多
登录 后发表回答