我已经成功创建了mysql数据库转储文件(utf8):
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();
我可以通过使用带有这个单行命令的 windows CMD 成功地将 utf8 转储文件恢复到数据库中:
mysql.exe -u root --password=1234 databasename < d:\backup.sql
但是,我未能在 C# 中执行该命令。你能告诉我哪里出了问题。非常感谢你。以下是我的命令:
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();