Backing up Database in MySQL using C#

前端 未结 6 1224
有刺的猬
有刺的猬 2020-12-14 04:06

I created a Winforms in order to backup my Database. Then When I run my program it gives an Win32Exception was unhandled. \"The system cannot find the file specified\" Altho

6条回答
  •  [愿得一人]
    2020-12-14 05:04

    ProcessStartInfo psi = new ProcessStartInfo();
    psi.FileName = @"C:\\xampp\mysql\bin\mysql.exe";
    psi.RedirectStandardInput = true;
    psi.RedirectStandardOutput = false;
    psi.CreateNoWindow = true;
    psi.Arguments = string.Format(@"-u{0} -p{1} -h{2} {3}<{4}", "root", "password", "localhost", "your_dbname", "your_.sql_file");
    psi.UseShellExecute = false;
    Process process = Process.Start(psi);
    process.StandardInput.WriteLine(input);
    process.StandardInput.Close();
    process.WaitForExit();
    process.Close();
    

    This one worked for me you can try it out as long as you've your backed up .sql file

提交回复
热议问题