As I follow from the documentation, The import command in its most basic form is:
mysql.exe < example.sql
It works when I run it from the command line in Windows. But it doesn't work when I start the process mysql.exe
with < example.sql
parameters. For example, creating a shortcut and setting its path to mysql.exe < example.sql
doesn't work and it only prints the help info for mysql.exe
.
As a side note, I first noticed this problem when trying to run the following C# code:
new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "mysql.exe",
Arguments = "< example.sql",
}
}.Start();
2 Answers 2
The part < example.sql
does not contitute parameters for mysql.exe
; the <
character denotes a redirection operator, so the content of file example.sql
is redirected into mysql.exe
.
I guess you have to change the file name to cmd.exe
and the arguments to /C "mysql.exe < example.sql"
. Consider to specify full absolute paths to all of the files.
Comments
I don't work in windows but I assume you best fill in the full path + database hostname information:
C:\mysql\directory\bin\mysql -h {hostname} -u {username} -p {databasename} < example.sql
1 Comment
example.sql
; each path quoted to avoid trouble with white-spaces and other special characters...
< example.sql
are not parameters formysql.exe
, the<
denotes a redirection operator, so the content of fileexample.sql
is redirected intomysql.exe
; I guess you have to change the file name tocmd.exe
and the arguments to/C "mysql.exe < example.sql"
; consider to specify full absolute paths to all of the files...mysql.exe
. Also you can turn your comment into answer. It answers my question.mysql.exe
. Just wait a minute to get my comment converted to an answer...