I am working on a C# application in which I have to make a copy of an already existing database schema in MySQL. I am using mysqldump.exe
to accomplish the task. Within a process I execute mysqldump.exe
and I pass the required arguments to the process. Below is my process code.
ProcessStartInfo proc = new ProcessStartInfo();
proc.Arguments = @"-h localhost --port 33060 -u root -p1234 MasterDB | mysql -h localhost --port 33060 -u root -p1234 ChildDB";
proc.FileName = @"C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqldump.exe";
proc.UseShellExecute = false;
proc.RedirectStandardOutput = true;
Process p = Process.Start(proc);
using (StreamReader reader = p.StandardOutput)
{
string result = reader.ReadToEnd();
Console.Write(result);
}
p.WaitForExit(60000);
When I execute mysqldump.exe from DOS with same arguments it runs fine and make a copy of masterDB schema into childDB. But from within this C# code it doesn't work.
There is some problem with the argument string I am passing to the process. In console application it shows me the error "could not find table". I have tried to make up string different ways but nothing worked for me.