3

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();
asked Nov 9, 2016 at 8:50
4
  • what did you mean by this mysql.exe with < example.sql parameters Commented Nov 9, 2016 at 9:08
  • < example.sql are not parameters for mysql.exe, the < 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... Commented Nov 9, 2016 at 9:17
  • @aschipfl Do you know a way to pass the sql file as parameter to mysql.exe. Also you can turn your comment into answer. It answers my question. Commented Nov 9, 2016 at 9:29
  • Unfortunately I cannot help you with mysql.exe. Just wait a minute to get my comment converted to an answer... Commented Nov 9, 2016 at 9:41

2 Answers 2

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.

answered Nov 9, 2016 at 9:44

Comments

0

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
answered Nov 9, 2016 at 9:17

1 Comment

...and also the full path to example.sql; each path quoted to avoid trouble with white-spaces and other special characters...

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.