I would like to restore my database in MySQL.
When I try manually using cmd to execute the command, it actually restores into the database but when in C# codes, it does not work.
Please help me see where's the error. Thanks!
using System.IO;
using System.Diagnostics;
开发者_运维百科 Process process = new Process();
process.StartInfo.FileName = @"C:\Program Files\MySQL\MySQL Server 5.1\bin\mysql.exe";
process.StartInfo.Arguments = @"--verbose --user=root --password=qwerty123456 test < C:\Users\Aaron\testing.SQL";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
process.Start();
I don't imagine that < C:\Users\Aaron\testing.SQL
is supported when creating a process, it's syntax specific to the command prompt. Try cmd /c your_app.exe arguments < file
instead.
精彩评论