I have created the mysql database dump file(utf8) successfully with this:
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = Application.StartupPath + "\\mysqldump.exe";
psi.RedirectStandardInput = false;
psi.RedirectStandardOutput = true;
psi.Arguments = "-r D:\\backup.sql --user=root --password=1234 --opt databasename";
psi.UseShellExecute = false;
Process process = Process.Start(psi);
process.WaitForExit();
process.Close();
I am able to restore the utf8 dump file into database successfully by using windows CMD with this single line command:
mysql.exe -u root --password=1234 databasename < d:\backup.sql
but, I failed to execute the command in C#. Could you please advice me where is gone wrong. Thanks you very much. Below are my commands:
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = Application.StartupPath + "\\mysql.exe";
psi.RedirectStandardInput = false;
psi.RedirectStandardOutput = false;
psi.Arguments = "--user=root --password=1234 databasename < D:\\backup.sql";
psi.UseShellExecute = true;
Process process = Process.Start(psi);
process.WaitForExit();
process.Close();