title: Why is dumping MySQL database programmatically different from dumping via command line?
body: <p>To dump database from command line, all I need to do is:</p>
  
  <pre><code>mysqldump -uroot --password=  myDb --routines&gt; "C:\s.sql"
  </code></pre>
  
  <p>So all I would try programmatically is this, which is the direct interpretation of it I suppose:</p>
  
  <pre><code>ProcessStartInfo psi = new ProcessStartInfo();
  psi.FileName = dumpUtilityPath;
  psi.RedirectStandardInput = false;
  psi.RedirectStandardOutput = true;
  psi.UseShellExecute = false;
  psi.CreateNoWindow = true;
  
  psi.Arguments = "-uroot --password=  myDb --routines&gt; \"C:\\s.sql\"";
  
  Process process = Process.Start(psi);
  process.WaitForExit();
  process.Close();
  </code></pre>
  
  <p>Which doesn't work at all. Instead I have to go for this which one can find all over the net, which works too.</p>
  
  <pre><code>ProcessStartInfo psi = new ProcessStartInfo();
  psi.FileName = dumpUtilityPath;
  psi.RedirectStandardInput = false;
  psi.RedirectStandardOutput = true;
  psi.UseShellExecute = false;
  psi.CreateNoWindow = true;
  
  psi.Arguments = string.Format("-R -u{0} --password={1} -h{2} {3} --routines", "root", "", "localhost", "myDb");
  
  Process process = Process.Start(psi);
  string output = process.StandardOutput.ReadToEnd();
  process.WaitForExit();
  process.Close();
  
  using (StreamWriter writer = new StreamWriter("C:\\s.sql"))
  {
      writer.WriteLine(output);
      writer.Close();
  }
  </code></pre>
  
  <ol>
  <li><p>Why is that I need to use stream writer to get the database in an sql file which I can do otherwise directly from commands in command prompt?</p></li>
  <li><p>What is the role of -R in the second block?</p></li>
  </ol>