PDA

View Full Version : Running MySQL.exe on setup to create a database



Andy
05-19-2011, 04:55 AM
Hello,
I've searched the forum and couldn't find what I was looking for.
My problem is running a MySQL script after the setup to create a database and the tables.
I tried it with the "run commandline" and the "run programm" function but none of them worked.
To execute the script I use mysql.exe with the parameters -u %USER% -p %PASSWORD% -h %SERVER% < "script.sql"
If I run this line directly into the cmd it works as expected and the database is created but not so out of the installer.

Can you give me a hint, what i'm doing wrong?
I use the SetupBuilder v7.1 Dev on WinXP
The command line string is "%_SB_INSTALLDIR%\MySQL\mysql.exe" -u %USER% --p %PASSWORD% -h %SERVER% < "%_SB_INSTALLDIR%\MySQL\CreateDatabase.sql".
I don't know what to do or what i could try.

Thanks!
Andy

linder
05-19-2011, 05:05 AM
Andy,

I don't think that your command line is correct at all. Please note that a Windows application (e.g. your setup.exe) makes use of CreateProcess or ShellExecuteEx Windows APIs to launch another program.

Friedrich

linder
05-19-2011, 05:15 AM
BTW, perhaps your intention was to run the command interpreter? In this case you have to use cmd /c in front of your command.

Friedrich

Unregistered
05-19-2011, 05:40 AM
BTW, perhaps your intention was to run the command interpreter? In this case you have to use cmd /c in front of your command.

Friedrich

Yes, exactly. Sorry about that.
That means i have to do launch the mysql.exe with "run programm"? Ok, i'll give it a try.
Thank you for your advice.
Now, all i have to do is to find out, how to pass the parameters correctly to the call.

Thanks!
Andy

linder
05-19-2011, 05:47 AM
Hi Andy,

IMO, "Run Command Line..." should also work for you. But you have commands in your command line that are typical for a "command interpreter" call. For example, "<" is a redirection operator and only available in CMD.EXE. Neither the CreateProcess nor the ShellExecuteEx Windows API have any idea what "<" means.

So just put cmd /c in front of your original command line and you should be done. This will then launch the command interpreter (CMD.EXE).

Does this help?

Friedrich

Andy
05-19-2011, 06:10 AM
Hi Friedrich

Hey, it' working right now.
Thank you!
You were right to put the cmd /c in front of the command line.
Whats a little bit strange is, is the fact that it doesn't work if you call it with "cmd.EXE /c" or "[SYS]\cmd.exe /c".
It has to be "cmd /c".

Andy

linder
05-19-2011, 06:38 AM
Hi Andy,

Perfect!

Friedrich