If I type this into command window:
"D:\databases\MySQL-5_0(x64)\bin\mysql.exe" -u root betting < "W:\data\projects\temp\example.sql"
That works
Next task is running above from my own computer program...
1) Using shellexecute directly to call mysql with above parameters does not work for me. Studying SO I found that the reason is CMD doing the pipe > stuff.
2) Call shellexecute on cmd.exe wih params being
cmd /c "D:\databases\MySQL-5_0(x64)\bin\mysql.exe" -u root betting < "W:\data\projects\temp\example.sql"
Delphi code example:
S := '"D:\databases\MySQL-5_0(x64)\bin\mysql.exe" -u root betting < "W:\data\projects\temp\example.sql"';
S := '/c ' + S;
ShellExecute(
0,
'open',
'cmd.exe',
PChar(S),
nil,
SW_SHOWMAXIMIZED
);
Does not work either.
To see what the problem was, I tried putting the following into an already open command line prompt window like this:
cmd.exe /c "D:\databases\MySQL-5_0(x64)\bin\mysql.exe" -u root betting < "W:\data\projects\temp\example.sql"
which gives error
'D:\databases\MySQL-5_0' is not recognized as an internal or external command, operable program or batch file.
This puzzled me as my usage of double-quotes should be correct. But trying this instead:
cmd.exe /c "mysql.exe" -u root betting < "W:\data\projects\temp\example.sql"
still gives an error:
'mysql.exe' is not recognized as an internal or external command, operable program or batch file.
I have reached the end of the line of things to try I think.
Can anyone shed some light on how to successfully execute mysql from a program passing a commandline instruction ha instructs mysql to execute a SQL file?